Skip to content

Instantly share code, notes, and snippets.

@akbyrd
Created October 16, 2023 18:15
Show Gist options
  • Save akbyrd/4b8a6b47ef8af792df5f534a86a3cf89 to your computer and use it in GitHub Desktop.
Save akbyrd/4b8a6b47ef8af792df5f534a86a3cf89 to your computer and use it in GitHub Desktop.
Quick 'n' Dirty Build Profiling
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
$isAdmin = (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
if (-Not $isAdmin)
{
Start-Process pwsh -Wait -Verb RunAs -ArgumentList "-Command $PSCommandPath $args; pause"
return
}
$fileName = $args
if ($fileName)
{
$singleFile = "-File=`"${fileName}`""
}
$useWPA = $false
$usePerfetto = $true
$vcperf = "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\bin\Hostx86\x86\vcperf.exe"
.$vcperf /stopnoanalyze build-profile build-profile-raw.etl
Remove-Item build-profile-raw.etl 2>&1 | Out-Null
Remove-Item build-profile.etl 2>&1 | Out-Null
Remove-Item build-profile.json 2>&1 | Out-Null
function AnalyzeAndOpenInWPA
{
if ($useWPA)
{
.$vcperf /analyze /templates build-profile-raw.etl build-profile.etl && `
wpa -i build-profile.etl
}
}
function AnalyzeAndOpenInPerfetto
{
if ($usePerfetto)
{
.$vcperf /analyze /templates build-profile-raw.etl /timetrace build-profile.json && `
python (Get-Command open_trace_in_ui.py).Source -i build-profile.json
}
}
# TODO: /noadmin https://github.com/microsoft/vcperf/issues/35
.$vcperf /start /level3 build-profile && `
Write-Host Build.bat DragonEditor Win64 DebugGame $singleFile && `
.\Engine\Build\BatchFiles\Build.bat DragonEditor Win64 DebugGame $singleFile && `
.$vcperf /stopnoanalyze build-profile build-profile-raw.etl && `
AnalyzeAndOpenInWPA && `
AnalyzeAndOpenInPerfetto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment