Skip to content

#010 PROFILING AL PERFORMANCE WITH SNAPSHOT DEBUGGER

Performance is always on our mind for us and our customers as well. Until now, we did not have a practical tool to monitor the execution time of our code and with that to help us in performance analysis. With the release of Dynamics 365 Business Central 2021 Wave 2 Release (a.k.a. BC19), Microsoft gave us the possibility to capture execution time as part of the snapshot, and enabled us to watch it in Visual Studio Code while replaying the snapshot.

 

In the previous Tips #33 (Snapshot Debugging: Run Code on Server and Debug in VS Code), we learn how to use the Snapshot Debugger. Now, with BC19 we have a new feature added – the “executionContext” property.

This new property has the following list of options:

1. Debug: No profile data is collected;

2. DebugAndProfile: Debug and profiling will occur;

3. Profile: Only profiles the session, ignores the snappoints.

In the following example we used the DebugAndProfile option.

In the following example we used the DebugAndProfile option.

When the snapshot file download is completed, we can run the AL: Generate profile file command, and we choose the respective downloaded file.

AL Generate profile file command,

After this, our performance profile file will be downloaded and opened.

Now, we are able to trace the execution triggers, procedures, events and so on.

we are able to trace the execution triggers

In this last image, we can see the time in milliseconds that took our function to run, and we can now understand the impact that our solution is having on performance.