0

I have the following script to measure the current cpu clock rate from this [link][1].

$MaxClockSpeed = (Get-CimInstance CIM_Processor).MaxClockSpeed
$ProcessorPerformance = (Get-Counter -Counter "\Processor Information(_Total)\% Processor Performance").CounterSamples.CookedValue
$CurrentClockSpeed = $MaxClockSpeed*($ProcessorPerformance/100)

I am looking to test the performance of the CPU to see how far it can go in terms of frequency.

The reason for this is that we have a few machines that are faulty out of our hundreds of machines, and it turns out that when you push them a bit, their clock rate doesn't change and stays at around 20% utilization. This would allow us, via our monitoring system, to find them easily.

Is there a way to programmatically via powershell to make an intensive task during or just before capturing the actual clock speed to know how far it can get? Something like a loop or something? [1]: Unable to get current CPU frequency in Powershell or Python

Andy McRae
  • 525
  • 7
  • 15

1 Answers1

0

I found something interesting on this website. So to make the cpu work at 100% for a short time, I can use a background job:

$NumberOfLogicalProcessors = Get-WmiObject win32_processor | Select-Object -ExpandProperty NumberOfLogicalProcessors
 
ForEach ($core in 1..$NumberOfLogicalProcessors){ 
 
start-job -ScriptBlock{
 
    $result = 1;
    foreach ($loopnumber in 1..2147483647){
        $result=1;
        
        foreach ($loopnumber1 in 1..2147483647){
        $result=1;
            
            foreach($number in 1..2147483647){
                $result = $result * $number
            }
        }
 
            $result
        }
    }
}
 
Read-Host "Press any key to exit..."
Stop-Job * 

It makes the cpu go usually at 100% of utilization. During that time I can easily run the script:

$MaxClockSpeed = (Get-CimInstance CIM_Processor).MaxClockSpeed
$ProcessorPerformance = (Get-Counter -Counter "\Processor Information(_Total)\% Processor Performance").CounterSamples.CookedValue
$CurrentClockSpeed = $MaxClockSpeed*($ProcessorPerformance/100)

For instance, in my case, when I test the $processorPerformance I get "107.998029830411" as an example, so this shows My processor works fine when I push it.

N.B I must add the Start-sleep -Seconds 20 parameter while the background tasks are running, because on all the machines it takes around 15 seconds until the x logical processors are running at 100%.

Andy McRae
  • 525
  • 7
  • 15