$theTitle=wp_title(" - ", false); if($theTitle != "") { ?>
About Virtualization, VDI, SBC, Application Compatibility and anything else I feel like
To get the best performance out of Virtual Desktops it is essential that the power configuration in the system BIOS and the HyperVisor are configured for maximum performance.
Many people have blogged about the importance of these settings like, Andrew Wood, Helge Klein and Didier Van Hoye. So I will not go into details again.
But how do you check from a Virtual Machine if you are actually running at full clock speed or not?
I have written a PowerShell script to do just that (requires at least PowerShell v3).
Here are some screenshots:
Running with "High Performance profile":
Running with "Balanced" power profile:
Here is the script (download link at the bottom):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # How many times to query clockspeed $count = 100 # Interval in ms $interval = 50; # Little helper to add colours to output filter ColorPattern( [string]$Pattern, [ConsoleColor]$Color, [switch]$SimpleMatch ) { if( $SimpleMatch ) { $Pattern = [regex]::Escape( $Pattern ) } $split = $_ -split $Pattern $found = [regex]::Matches( $_, $Pattern, 'IgnoreCase' ) for( $i = 0; $i -lt $split.Count; ++$i ) { Write-Host $split[$i] -NoNewline Write-Host $found[$i] -NoNewline -ForegroundColor $Color } Write-Host } #Get Maximum Clock Speed (once because WMI is slow) $maxClockSpeed = (get-wmiobject Win32_Processor | select-object -first 1).MaxClockSpeed #default color $highlighColor = 'Green' function GetClockSpeed() { $freq = Get-Counter -Counter "\Processor Information(*)\Processor Frequency" $item = New-Object System.Object foreach ($cpu in $freq.CounterSamples) { $procNum = ([RegEx]::Match($cpu.Path, '.+\((\d+,\d+)\).*')).Groups[1].Value if ($procNum) { $item | Add-Member -Type NoteProperty -Name $procNum -Value $cpu.CookedValue } } $item } for ($i=0 ; $i -lt $count ; $i++) { $list = GetClockSpeed cls $firstCoreSpeed = ($list | Select-Object -ExpandProperty "0,0") # Just some formatting magic, make it green if full speed and red otherwise if ($firstCoreSpeed -lt $maxClockSpeed) { $highlighColor = 'Red' } else { $highlighColor = 'Green' } "Actual: {0} Mhz Maximum: {1} Mhz -> {2:P0}" -f $firstCoreSpeed, $maxClockSpeed, ($firstCoreSpeed / $maxClockSpeed) | ColorPattern -Pattern '\d+ %' -Color $highlighColor "Speed per Core:" $list | Format-Table -AutoSize | Out-String | ColorPattern -Pattern '\d\d+' -Color $highlighColor #-SimpleMatch # Sleep until next interval Start-Sleep -Milliseconds $interval } |
2 Responses for "Get Actual CPU Clock Speed with PowerShell"
Like this one, great work Remko!
Unfortunatley this reports only the stock speed on a machine with HyperV enabled. Even with Power Saver set, confirmed with Cpu-Z
You could use HyperV Hypervisor\Logical Processor\Frequency – this is accurate below stock freq but will not report Turbo freq (Win8.1)
Leave a reply