Command Prompt Computer

Track Your CPU Usage LIVE With Command Prompt

To view your current CPU Usage in Windows you can go to Task Manager or Resource Monitor. But how to save those data for a long duration to analyze them later ? Today I will tell you how with command prompt you can continuously track your CPU usage and can store the data in CSV format. The command typeperf will do your work.

Different ways to track you CPU Usages

You can track your individual CPU usages and also total CPU usages. Only you need to change some parameters to get different results. You have to set some parameters like at how many interval the readings will be taken and how much reading will be recorded, where the data will be stored etc.

  • Recording your total CPU usage
    You have to mentioned the parameter as Processor(_total). See below command for better understanding.

  • Recording a particular Processor's usage
    You have to mentioned the parameter as Processor(<CPU number>). See below command for better understanding.

  • Recording all Processor's usages simultaneously
    You have to mentioned the parameter as Processor(*). See below command for better understanding.

  • Set the time between two reading
    In above 3 commands the reading will be taken in every 1 sec. If you want to increase the sample interval then you have to mentioned the parameter as -si <mm:ss>. For example, if I want to take the readings in each 5 secs, then I need to set the parameter as follow

  • Set the number of samples to collect
    If you want to collect unlimited number of readings then don't need to set this parameter. Hence all 4 commands mentioned above will continue reading data until you press Ctrl+c. But if you want to restrict your output to some finite samples then you have to set the parameter as -sc <number>. For example, if I want to take only 7 readings then I will write as follow.

  • Save the the usages in a CSV file
    This is applicable to all 5 commands mentioned above. That means you can store all of their output in CSV format. You can do this in two ways. The first is the universal way i.e put >> at the end of the command and mention a file name to save. The second is by mentioning one parameter as -o <file name>. Just have a look on below commands for better understanding

Homework
Now tell me what you can do with following commands

  • typeperf "Processor(_Total)% Processor Time" -si 3 -sc 5
  • typeperf "Processor(*)% Processor Time" -si 3 -o CpuUsage.csv
  • typeperf "Processor(_Total)% Processor Time" -si 3 -sc 15 -o CpuUsage.csv

Leave a Reply

Your email address will not be published. Required fields are marked *