MegaBites-AI/Windows-powershell
0372
1 2# PowerShell Performance Analysis3 4This directory contains useful scripts and related files for analyzing PowerShell performance.5 6If you use the [Windows Performance Toolkit](https://learn.microsoft.com/windows-hardware/test/wpt/), you can use the following to collect data and analyze a trace.7 8```PowerShell9$PowerShellGitRepo = "D:\PowerShell"10wpr -start $PowerShellGitRepo\tools\performance\PowerShell.wprp -filemode11pwsh.exe -NoProfile -Command "echo 1"12wpr -stop PowerShellTrace.etl13wpa -i wpa://.\PowerShellTrace.etl?profile=$PowerShellGitRepo\tools\performance\PowerShell.wpaProfile14```15 16When wpa opens, under System Activity, you'll find a section "Regions of Interest".17With the above wpaProfile, you should see a bunch of PowerShell related regions as well as GC and JIT activity.18 19If you use [PerfView](https://github.com/microsoft/perfview), you can collect a trace by running20 21```PowerShell22Invoke-PerfviewPS.ps1 -scenario { echo 1 }23perfview .\perfviewdata.etl24```25 26The etl files collected with perfview or wpr should contain roughly the same events.27 28Also note that you can collect the trace with one tool and analyze with the other.29 30## Symbols31 32PDB files are not published for PowerShell Core,33so the current recommendation is to build PowerShell yourself passing `-CrossGen` to `Start-Build`.34 35If profiling Windows PowerShell, symbols are generated from GAC.36wprui.exe and perfview.exe will both generate the PDB files needed.37 38## Files39 40| File | Description |41| ---- | ----------- |42| GC.Regions.xml | WPA regions of interest for GC |43| JIT.Regions.xml | WPA regions of interest for JIT |44| PowerShell.Regions.xml | WPA regions of interest for PowerShell |45| PowerShell.stacktags | PowerShell stack tags |46| PowerShell.wpaProfile | WPA profile to load regions of interest and stack tags |47| PowerShell.wprp | WPR profile to enable CLR and PowerShell ETW events |48| Invoke-PerfviewPS.ps1 | Script to run perfview and with PowerShell ETW events enabled |49 50 