Profiling
Performance profiler for PowerShell Universal.
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.
Enable Profiling
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.
Access Profiling Data
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-3b9440123704426f62ac5135b3cc01251b8c56d0%252Fimage%2520%28432%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=aaf165f9&sv=1)
Clicking on the request will display a break-down of the timings.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-86dec8fbee0bb49e6a8260003e93073a6f7fbc4a%252Fimage%2520%28266%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=51488a96&sv=1)
Profiling an API Endpoint
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-90d0ed95e7af20afbf6f83422563c1f8e19795a2%252Fimage%2520%28440%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=d9358fb5&sv=1)
Viewing the profile for this API would list the block we measured.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-39e46d3a41103043d9c8eea35c5d57fe4e982419%252Fimage%2520%28556%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=36532a3c&sv=1)
Profiling an App
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-44927d0b8d6428df12d6bca4432ca1526ffb6fa0%252Fimage%2520%28264%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=1154ead2&sv=1)
Not all timing will be displayed by default. You can click show trivial
to expand all timings.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-aea57bc5b672e552dc0902c7fceb66770c59fe36%252Fimage%2520%28549%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=7e05ee17&sv=1)
Profiling a Job
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.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-42e704ea3011e0e9e03aa9c67705fbc0eeb8576c%252Fimage%2520%28554%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=cc243b64&sv=1)
The profile will include the block that was measured.
![](https://docs.powershelluniversal.com/~gitbook/image?url=https%3A%2F%2F1373299915-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F8F6PrkNTG8Y34hADzKOL%252Fuploads%252Fgit-blob-b8ea7cfe8f5a29d8aac140e2f917c13b088c452e%252Fimage%2520%28111%29.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=bebc7e04&sv=1)
Last updated