- Aug
- 2,308
- 111
On my Windows 7 64-bit system, I can use resource monitor to see the CPU usage for each of the eight cores on my system;
However, I would like to see this info via the command line.
Here is a .BTM that allows me to do that;
Sample run;
Joe
However, I would like to see this info via the command line.
Here is a .BTM that allows me to do that;
Code:
@setlocal
@echo off
COMMENT
Tested on;
TCC 24.00.24 x64 Windows 7 [Version 6.1.7601]
TCC Build 24 Windows 7 Build 7601 Service Pack 1
The first time this .BTM is run, it would seem to be hung, but subsequent runs are immediate.
ENDCOMMENT
:: A couple of functions to get what I want;
::
function ProcessorTime=`%@wmi[root\CIMV2,"select PercentProcessorTime from Win32_PerfFormattedData_PerfOS_Processor where name = '%1'"]`
function UserTime=`%@wmi[root\CIMV2,"select PercentUserTime from Win32_PerfFormattedData_PerfOS_Processor where name = '%1'"]`
::
:: TCC can tell me how may processors I have;
::
set Processors=%@wininfo[3]
:: Zero-base the Processors
::
set Processors=%@dec[%Processors]
::
:: Show the ProcessorTime and UserTime as a percentage for each Processor
::
echo Processor # ProcessorTime UserTime
do Processor=0 to %Processors
echo %@format[11,%Processor] %@format[13,%@ProcessorTime[%Processor]] %@format[8,%@UserTime[%Processor]]
enddo
endlocal
Sample run;
Code:
Processor # ProcessorTime UserTime
0 87 93
1 37 24
2 62 62
3 100 99
4 87 81
5 56 74
6 87 62
7 69 80
Joe
Last edited: