Reputation: 21
I am trying to get Powershell to give me the average CPU usage of a code block, but can't figure out what wmi class to use.
This only gives me the current usage:
Get-WmiObject win32_processor | Measure-Object -property LoadPercentage -Average | Select Average
Upvotes: 2
Views: 167
Reputation: 24071
The class used will return data on CPU level. Try looking at process level to get more fine-grained numbers.
The member UserModeTime
contains the process' CPU time usage. A simple way to convert it into more readable values is to use TimeSpan
like so, [TimeSpan]::FromMilliseconds()
Upvotes: 0