Profiling
Performance profiler for PowerShell Universal.
Last updated
Performance profiler for PowerShell Universal.
Last updated
Profiling only works for the integrated environment.
PowerShell Universal provides a performance profiler for debugging issues where the platform may exhibit slow responses. This is primarily useful when building Dashboards.
Profiling will increase memory usage as profiling data is stored in memory. You can enable profiling by configuring the Profiling
appsettings.json property. It is false
by default. You will need to restart PowerShell Universal after enabling or disabling profiling.
You can access profiling data by navigating to /profiler/results-index
. You will need to be logged in as administrator before being able to access this URL.
You will see a list of requests and their timings.
Clicking on the request will display a break-down of the timings.
You can profile an API endpoint using Measure-PSUBlock
. The API will be listed by URL in the result index.
For example, assume an API called /process
.
The result of profiling this API would be listed by URL.
Viewing the profile for this API would list the block we measured.
Measure-UDBlock
is an alias for Measure-PSUBlock
You can use the built-in profiler with Apps. By default, certain internal action timings are recorded. You can also use the Measure-PSUBlock
cmdlet to measure specific blocks within your dashboard.
For example, this app uses Measure-PSUBlock
to measure the performance of the Start-Sleep
cmdlet. The result is the block will take one second to execute.
When reviewing requests within the profiler, you will want to look for UDComponent\ElementPost
and UDComponent\Element
. These are requests for elements within Apps.
Below is the example output from the app shown above. Notice that the URL includes the element's ID MyElement
. You'll also notice that the WithinDashboard
block takes about 1 second.
Not all timing will be displayed by default. You can click show trivial
to expand all timings.
You can profile jobs by using Measure-PSUBlock
within your script.
For example, assume we have a script that calls Get-Service
.
Running a profile on this script will list the job as JobProfiler/{id}
. The id will match the job ID shown in the admin console.
The profile will include the block that was measured.