As part of the PowerShell Pro Tools module, profiling support has been integrated into the PowerShell Pro Tools VS Code extension. You can use the
PowerShell: Profile Script command to execute the profiler on the currently active PS1 file.
The profiler will annotate the script with information about the performance and call count of each of the pipelines within the script.
If you wish to remove the code annotations, you can use the
PowerShell: Clear Profiling Information and your editor will be back to the state it was in before profiling.
You will need to install the latest version of the PowerShell Pro Tools module (1.10.0+) for this functionality to work.
Being an early version of the profiler, there are some limitations.
The profiler only profiles the current script. It will not profile scripts or modules that you reference. If you use functions within pipelines in your profiled script, those functions will be timed but their internal operations will not.
Hot Path Support
Although the hot path information is available in the output from the profiler, there is no visual representation of this information.
The profiler has early support for pipeline element timing but does not expose this in this version. For example, a pipeline like the one below will result in a single timing even though multiple commands are being called.
Get-Process | Select-Object Name | Out-String 40.85% (1 calls)
In a future version, individual commands will be able to be profiled.