{"title":"AL Profiler overview","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-al-profiler-overview/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-al-profiler-overview, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-al-profiler-overview","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Use instrumentation or sampling with the AL Profiler to analyze AL execution, SQL activity, call stacks, and performance hot spots.","date":"2026-10-07","meta":{"topic":"overview"},"outline":[{"level":2,"title":"When to use the AL Profiler","slug":"when-to-use-the-al-profiler","at":955,"chars":334},{"level":2,"title":"Basic workflow","slug":"basic-workflow","at":1289,"chars":405},{"level":2,"title":"Snapshot of the running code","slug":"snapshot-of-the-running-code","at":1694,"chars":483},{"level":2,"title":"Snapshot configuration settings","slug":"snapshot-configuration-settings","at":2177,"chars":3059},{"level":3,"title":"To set up a snapshot configuration for instrumentation profiling","slug":"to-set-up-a-snapshot-configuration-for-instrumentation-profiling","at":2431,"chars":1166},{"level":3,"title":"To set up a snapshot configuration for sampling profiling","slug":"to-set-up-a-snapshot-configuration-for-sampling-profiling","at":3597,"chars":1639},{"level":2,"title":"Getting a snapshot file","slug":"getting-a-snapshot-file","at":5236,"chars":631},{"level":2,"title":"Generating a profile file for instrumentation profiling","slug":"generating-a-profile-file-for-instrumentation-profiling","at":5867,"chars":4942},{"level":3,"title":"Graph of method calls","slug":"graph-of-method-calls","at":6381,"chars":2790},{"level":4,"title":"View modes","slug":"view-modes","at":7345,"chars":333},{"level":4,"title":"Details","slug":"details","at":7678,"chars":569},{"level":4,"title":"Filter","slug":"filter","at":8247,"chars":924},{"level":5,"title":"Column name aliases","slug":"column-name-aliases","at":8518,"chars":653},{"level":6,"title":"Filter examples","slug":"filter-examples","at":8900,"chars":271},{"level":3,"title":"Keyboard shortcuts for navigating the graph","slug":"keyboard-shortcuts-for-navigating-the-graph","at":9171,"chars":652},{"level":3,"title":"Inline Profiler CodeLens for AL profiling results","slug":"inline-profiler-codelens-for-al-profiling-results","at":9823,"chars":986},{"level":2,"title":"Sampling profiling","slug":"sampling-profiling","at":10809,"chars":1222},{"level":3,"title":"In-client performance profiling","slug":"in-client-performance-profiling","at":11566,"chars":465},{"level":2,"title":"Related information","slug":"related-information","at":12031,"chars":226}],"text":"> INTRODUCED IN: Business Central 2021 release wave 2\nSampling profiling was added in Business Central 2022 release wave 1.\nThe AL Profiler helps you analyze performance hot spots in Business Central extensions by recording execution details from a snapshot of running code. It supports two complementary modes. Instrumentation records every executed frame and provides detailed timings and call counts. Sampling periodically captures the active stack and generally has lower profiling overhead, but its timings are estimates. Sampling also surfaces SQL call activity, including in-client profiling.\nUse the profiler to validate optimizations, isolate slow pages or processes, distinguish AL execution time from SQL time, and compare alternative implementations. Profiles open in Visual Studio Code with top-down and bottom-up call stack views, filtering, and color coding by application layer. CodeLens can inline timing and hit data directly in source.\n## When to use the AL Profiler\n When users report that specific pages or processes run slower than expected.\n When you're optimizing your extension before publishing it to Marketplace.\n When you want to validate performance improvements in your code.\n When you need to identify which parts of a complex process consume the most time.\n## Basic workflow\n1. Configure an instrumentation or sampling snapshot in launch.json.\n2. Capture and download the snapshot.\n3. Generate an `.alcpuprofile` file, or record one in the client.\n4. Explore call graphs, timings, hit counts, and SQL calls available in sampling profiles.\nApply filters to focus on the most expensive methods. Use profiling early and iteratively to keep performance predictable.\n## Snapshot of the running code\nBy using the AL Profiler for the AL Language extension for Microsoft Dynamics 365 Business Central, you can capture a performance profile from a snapshot of running code. Instrumentation profiling provides more accurate and detailed results. Sampling profiling is less accurate but can reveal performance trends faster. In the Visual Studio Code performance profiling editor, use top-down and bottom-up call stack views to investigate execution time.\n## Snapshot configuration settings\nBefore profiling code, configure and capture a snapshot in launch.json. The configuration depends on the profiling type. Learn more about snapshot configuration in devenv-snapshot-debugging and devenv-json-launch-file.\n### To set up a snapshot configuration for instrumentation profiling\nThe executionContext parameter supports the following values. If you omit it, the default is DebugAndProfile.\nOption|Description\nDebug|The snapshot session doesn't gather profile information.\nProfile|The snapshot session gathers only profile information, ignores snappoints, and doesn't support debugging.\nDebugAndProfile|The snapshot session supports both debugging and profiling. This value is the default.\nThe profilingType must be set to Instrumentation as illustrated in the example below.\nTo use the snapshot for both debugging and profiling, configure launch.json as follows:\n```json\n\"configurations\": [\n        {\n            \"name\": \"snapshotInitialize: Your own server\",\n            \"type\": \"al\",\n            \"userId\": \"555\",\n            \"request\": \"snapshotInitialize\",\n            \"environmentType\": \"OnPrem\",\n            \"server\": \"http://localserver\",\n            \"serverInstance\": \"BC200\",\n            \"authentication\": \"Windows\",\n            \"breakOnNext\": \"WebClient\",\n            \"executionContext\": \"DebugAndProfile\",\n            \"profilingType\": \"Instrumentation\"\n        }\n```\n### To set up a snapshot configuration for sampling profiling\nFor sampling profiling, set profilingType to Sampling and executionContext to Profile in launch.json. Sampling profiling doesn't support debugging. Use the following configuration:\n```json\n\"configurations\": [\n        {\n            \"name\": \"Your own server\",\n            \"type\": \"al\",\n            \"userId\": \"555\",\n            \"request\": \"snapshotInitialize\",\n            \"environmentType\": \"OnPrem\",\n            \"server\": \"http://localserver\",\n            \"serverInstance\": \"BC200\",\n            \"authentication\": \"Windows\",\n            \"breakOnNext\": \"WebClient\",\n            \"executionContext\": \"Profile\",\n            \"profilingType\": \"Sampling\",\n            \"profileSamplingInterval\": 100\n        }\n```\nSupported sampling intervals are 50, 100, and 150 milliseconds. The default is 100 milliseconds.\n> > APPLIES TO: Business Central 2025 release wave 2 and later\nStarting with 2025 release wave 2, sampling profiling can track SQL calls in the web client's in-client profiler and in snapshots captured from Visual Studio Code. The in-client profiler automatically uses sampling. To track SQL calls in a Visual Studio Code snapshot, set profilingType to Sampling in launch.json.\nThe profile shows which SQL calls were made so you can determine whether slow performance is caused by AL code or by SQL. For scheduled profiles, the Performance Profiles data includes the sampling duration, activity duration, SQL-call duration, and number of SQL statements. When you drill into a specific profile, you can see the captured SQL calls. You can hover over them and copy the queries.\n## Getting a snapshot file\nAfter you define the configuration and set executionContext to DebugAndProfile or Profile, start a snapshot debugging session. Press Ctrl+Shift+P and select AL: Initialize Snapshot Debugging, or press F7.\nAfter initialization, the status bar displays the snapshot debugging session counter:\n![Visual Studio Code status bar showing the snapshot debugging session counter.]\nPress Alt+F7 to finish the session. Visual Studio Code lists the active snapshot sessions. Select a session to close it on the server and download its snapshot file. Learn more about snapshot debugging in devenv-snapshot-debugging.\n## Generating a profile file for instrumentation profiling\nAfter downloading the snapshot file, generate a profile file in one of these ways:\n1. Press Ctrl+Shift+P, select AL: Generate Profile File, and then select a snapshot from the drop-down list.\n1. Alternatively, in Visual Studio Code Explorer, right-click the snapshot file and select Generate Profile File.\nAL profile files use the `.alcpuprofile` extension. When you open a profile file, it appears in the Visual Studio Code performance profiling editor.\n### Graph of method calls\nOpen the generated profile file in the performance profiling editor. By default, the file opens in top-down view. Learn more about profile graph views in #view-modes. You can also right-click a profile file and select AL Profile Visualizer TopDown Graph or AL Profile Visualizer BottomUp Graph. The editor resembles the following image:\n![AL Profiler graph showing method calls and timing information.]\nUse the available view modes to investigate the graph. Select a method to navigate to its code. The default color legend is as follows:\nLayer|Color\nSystem Application|Green\nBase Application|Magenta\nOther extensions|Yellow\nSystem|Blue\nConfigure the color legend with al.profilerColors. Use al.profilerColors.apps to assign colors to named apps. Other extensions use the extension color, which is yellow by default. Learn more about profiler color configuration in AL Language Extension Configuration<devenv-al-extension-configuration>.\n#### View modes\nTo switch between views, right-click the profile file and select a view, or use the button in the upper-right corner. The graph has two view modes: top-down and bottom-up.\nIn top-down view, child nodes are methods called by the parent method. In bottom-up view, child nodes are methods that called the parent method.\n#### Details\nThe Self Time and Total Time columns are important indicators of where time is spent in the code. Self Time is the time spent in the method itself, excluding time spent in methods that it calls. Total Time is Self Time plus the time spent in methods that it calls. In bottom-up graphs, select the Self Time or Total Time heading to sort by that column. Select it again to reverse the sort direction.\nFor instrumentation profiles, the top-down view includes a Hit count column. The sampling top-down view doesn't show that column. Time spent is aggregated.\n#### Filter\nThe nodes in the graph can be filtered. The syntax is as follows:\n`@column name | <alias> <op> <value> where`<br>\n`<column name> := [function, url, path, selfTime, totalTime, id, objectType, objectName, declaringApplication, isBuiltinCodeUnitCall, hitCount]`\n##### Column name aliases\nThe aliases that are available for the column names are:\n`<alias> := [f, u, p, s, t, id, ot, on, da, b, h]`<br>\n`<op> := [numeric operators, boolean operators, string operators]`<br>\n`numeric operators : [:, =, >, <, <=, >=, <>, !=]`<br>\n`: := equal`<br>\n`boolean operators : [:, =, <>, !=]`<br>\n`string operators : [:, =, !=, <>, ~=]`<br>\n`~= := <regex>`\n###### Filter examples\nExpression|Result\n@t > 1000|Shows all nodes in the graph where the total time is greater than 1 second.\n@h > 20|Shows all nodes in the graph where the hit count was larger than 20.\n@da ~= ^Ba|Shows nodes whose declaring application starts with Ba.\n### Keyboard shortcuts for navigating the graph\nThe following table provides an overview of the shortcut key combinations that you can use when you're working in the graph of method calls.\nKeyboard Shortcut|Action\nEnter or Space|Expand or collapse the focused node.\nLeft arrow|Collapse a node.\nRight arrow|Expand a node.\nTab, then Enter|Focus the source link and open it.\nHome|Jump to the first node of the list.\nEnd|Jump to the last node of the list.\nDown arrow|Jump to the next node.\nUp arrow|Jump to the previous node.\n- (minus)|Collapse all nodes.\n* (star)|Expand one level for all nodes. Consecutive keystrokes expand the graph to the next level.\n### Inline Profiler CodeLens for AL profiling results\nThe Profiler CodeLens for AL shows profile results. It displays execution time and hit count inline for profiled statements. Statements below the al.statementLensMin threshold aren't shown.\nEnable general CodeLens support in the Visual Studio Code user or workspace settings by adding `\"editor.codeLens\": true`. To open the settings, press Ctrl+Shift+P and select Preferences: Open Settings (UI) or Preferences: Open User Settings.\nAdd two settings for AL Profiler CodeLens. `\"al.areProfileLensesSupported\": true` enables CodeLens and defaults to true. al.statementLensMin sets the minimum execution time, in milliseconds, for displaying a lens. Its default value is `500`. Learn more about these settings in AL Language Extension Configuration<devenv-al-extension-configuration>.\n> NOTE\n> Because of the aggregation of frames, there can be minor discrepancies between the information appearing in the CodeLens and in the profiler.\n## Sampling profiling\nUse sampling profiling for an initial analysis of AL code performance in Visual Studio Code. It captures the active AL stack frame at set intervals during an attached session. Sampling is less accurate than instrumentation, but it provides a faster, less noisy indication of an AL method's self-time.\nThe server applies the following restrictions to sampling profiling:\n A sampling session stops when it reaches the server's snapshot-debugger keep-alive interval. The default is one hour, but a profiling caller can supply a shorter limit.\n By default, the server stops sampling after the profile exceeds 10,000 cached sampled frame definitions. This limit is controlled by the internal MaxNumberOfCachedProfileSamples server setting.\n### In-client performance profiling\nIn Business Central, you can use the Performance Profiler page to record a sampling profile of a process that seems slow. The profiler generates an `.alcpuprofile` file that you can download and share. You can open the file in another Business Central Performance Profiler or in Visual Studio Code. Learn more about in-client profiling in In-client Performance Profiler overview<../administration/performance-profiler-overview>.\n## Related information\ndevenv-snapshot-debugging\nAL Language extension configuration<devenv-al-extension-configuration>\nIn-client performance profiler overview<../administration/performance-profiler-overview>\ndevenv-json-files"}