sots-re/verify/harness/profiling/timerres.ps1

11 lines
775 B
PowerShell

$src = @'
using System; using System.Runtime.InteropServices;
public class TR { [DllImport("ntdll.dll")] public static extern int NtQueryTimerResolution(out uint min, out uint max, out uint cur); }
'@
Add-Type -TypeDefinition $src
[uint32]$a=0; [uint32]$b=0; [uint32]$c=0
[TR]::NtQueryTimerResolution([ref]$a,[ref]$b,[ref]$c) | Out-Null
"timer resolution (100ns units): min(coarsest)=$a max(finest)=$b current=$c => current = $($c/10000.0) ms"
powercfg /energy /duration 5 /output C:\Users\re\energy.html | Out-Null
$h = Get-Content C:\Users\re\energy.html -Raw
if ($h -match '(?s)Platform Timer Resolution.{0,3000}') { ($Matches[0] -replace '<[^>]+>',' ' -replace '\s+',' ').Substring(0, [Math]::Min(1500, ($Matches[0] -replace '<[^>]+>',' ' -replace '\s+',' ').Length)) }