Dynamics 365 Business Central: using the Performance Toolkit to discover performance regressions

Probably many of you knows that Dynamics 365 Business Central has a tool called Performance Toolkit Extension (BCPT). This tool is useful to test performances of a Dynamics 365 Business Central environment and to discover how your code changes can impact them.

How to (I) use the BCPT tool?

The recommended way to start with the BCPT tool is to install the Performance Toolkit extension from the Extension Marketplace in Visual Studio Code. This extension is purpose-built to make it easy to set up the toolkit and start testing performances:

When this extension is installed, from VS Code create a project by running the BCPT Setup new Business Central Performance Toolkit project command:

Then select the target environment type, that can be a Docker-based environment or an online (SaaS) environment. Use Docker for Business Central on-premises:

Then sign in to your Business Central and select the environment:

and specify the directory where to create the project.

The output will be an extension project with a set of pre-defined test cases:

You can then start adding your own performance tests here. Test scenarios should be defined in a codeunit with SubType = Test, like for example the following (that tests opening the Item List page):

You can also define performance tests in a codeunit with SubType = Normal (not recommended). If the subtype is Normal, the test scenario should be defined in the OnRun trigger.

When defining tests, I normally also create some tests to control simple writing performances of the entire platform.

When all your performance tests are defined, you can then deploy your test extension and then you can configure a BCPT suite in Dynamics 365 Business Central.

To do that, in Dynamics 365 Business Central ssearch for BCPT Suites and choose the related link to create a new test suite:

When you configure a suite, you’ll need to specify:

  • What tests to run and, if applicable, with what parameters.
  • How many concurrent sessions you want to simulate for each test.
  • The duration of the scenario.

Explanation of all the available fields is available here.

Why performance tests should always be a best practice to adopt? Mainly for:

  1. Discover how your code works accordingly to different loads.
  2. Discover if your code generates performance regressions.
  3. Discover if Microsoft code (or a Microsoft upgrade) generates performance regressions.

I found BCPT extremely useful to discover regressions (and this is the main reason why I’m writing this post). I’ve recently talked with partners having performance problems after upgrades and the main reason was related to code changes. Here is an example of a code change that affected performances on sales orders:

BCPT test results before the changes:

BCPT test results after the changes:

But not all regression problems are always caused by your code (PTEs) or by third-party extensions code. Also a Microsoft upgrade could affect your performances unfortunately. And how you can discover that?

I usually do that using online sandboxes at first. The flow is:

  1. Create a new sandbox with your actual Dynamics 365 Business Central version.
  2. Execute your BCPT test suite and save results.
  3. Create a new sandbox with the new Dynamics 365 Business Central version.
  4. Execute your BCPT test suite and save results.
  5. Compare the results.

Results should be quite similar (or better, obviously). This is a nice practice also to test impacts on performances before applying a next major release (and there are not best days than this month to do that).

In this post I’ve also suggested to create performance tests for the infrastructure, like for example performing massive write operations, massive delete operations or sending calls to an HTTP endpoint. Why this?

Before in the past (and also recently) happened that updates caused performance degradations on this set of low-level operations (like for example of writing operations). BCPT tests help on discovering these problems too.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.