一些 xperf 用法
Start a trace
Boot test
xbootmgr -trace boot -numRuns 3 -resultPath C:\traces -postBootDelay 60 -traceFlags latency+dispatcher -stackWalk Profile+CSwitch+ReadyThread -prepsystem
We can use BIOSPOSTTime.ps1 to calculate BIOS POST time.
Be sure to modify the location of trace file in BIOSPOSTTime.ps1
Standby test
xbootmgr -trace standby -numRuns 3 -resultPath C:\traces -postBootDelay 60 -traceFlags base
Hibernation test
xbootmgr -trace hibernate -numRuns 3 -resultPath C:\traces -postBootDelay 60 -traceFlags base
Shutdown test
xbootmgr -trace shutdown -numRuns 3 -resultPath C:\traces -postBootDelay 60 -traceFlags base
Generate an XML summary
For shutdown test
xperf -i trace.etl -o summary.xml -a shutdown
For hibernation and standby test
xperf -i trace.etl -o summary.xml -a suspend
Show available actions
xperf -a /?
---
BIOSPOSTTime.ps1 (copied from Microsoft Velocity)
Run under powershell.exe
這個 ps1 檔其實就是抓 OSLoader 被執行的那個時間,然後按目前 CPU frequency 來換算回 BIOS POST 真正的時間。在 boot transition 的文章中已經看過整個 boot process 在 BIOS 之後即是 OSLoader,再對照這個可印證。
執行時記得確認 powershell 的權限沒問題,將 local machine 的權限改成 undefined or unrestricted 就可以啦!不過要 administrator 的權限就是了!
## Get_BIOSPOSTTime
##
## Checks Boot Traces to find BIOS POST Time
$outfile = New-Item -type file "C:\Velocity_Results\BIOSPostTime\BIOSPostTime.xml" -force
Add-Content $outfile " "
Add-Content $outfile " "
$search_string="OSLoader"
$processorSpeed = -1
$Boot_Traces=gci boot*.etl -path c:\traces -recurse
foreach ($trace in $Boot_Traces) {
if ($processorSpeed -eq -1) {
write-host "Getting Processor Speed..." -noNewLine
$sysconfig = (xperf -quiet -i $trace.FullName -a sysconfig)
[decimal]$processorSpeedGhz = $sysconfig[4].substring(16,4)
[decimal]$processorSpeed = $processorSpeedGhz * 1000000
write-host " $processorSpeedGhz Ghz ($processorSpeed)"
}
$search_results=xperf -i $trace.FullName -a dumper -range 0ms 1000ms | select-string $search_string
[string]$header_line = $search_results[0]
[string]$result_line = $search_results[1]
$split_header_line=$header_line.split(',')
$split_result_line=$result_line.split(',')
$column_index=0
foreach ( $column in $split_header_line ) {
if ($column.contains("OSLoaderStart")) {
break
}
$column_index++
}
[decimal]$BIOSPOSTCycles = $split_result_line[$column_index]
write-host "BIOS POST Cycle: " $BIOSPOSTCycles
write-host "Processor speed: " $processorSpeed
[decimal]$BIOSPostTime = ($BIOSPOSTCycles / $processorSpeed)
$BIOSPostTime = ("{0,6:N3}" -f $BIOSPostTime)
write-host "Trace: " $trace.Name -noNewLine
write-host "`tBIOS POST Time (sec): "$BIOSPostTime -foregroundcolor white
Add-Content $outfile " $BiosPOSTTime "
}
Add-Content $outfile " "
留言
張貼留言