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":

CPU Clock Speed with d"High Performanced" Power Profile

Running with "Balanced" power profile:

CPU Clock Speed with High Performance Balanced Profile

Here is the script (download link at the bottom):

ClockSpeed-v01.ps1 powershell Download
# 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
}

Download