Performance Monitor (perfmon) is a Windows tool used to view performance data. Although the name of the tool implies that it is only for performance, it also provides useful information that can be used for power analysis. In this blog, I will talk about perfmon in Windows 8 and how to use it to determine, at a high level, if your application can be optimized for power. This version has additional information that is useful for analyzing power not found in previous versions of Windows. Perfmon provides power information like CPU utilization (% processor time), system’s C States, Interrupt Rate, Context Switching rate, and system call rate. In Windows 8, it also provides information like clock interrupt rate and the wake up rate. This blog will concentrate on mobile platforms like Notebooks, Laptops, Ultrabook ™ running Microsoft* Windows 8. The guidance I am focusing on is application behavior while it is in an idle state (at rest, not actively doing anything.)
There are two ways to use perfmon. You can run it and view data in real time, or write data to a file.
Run and See Data in Real Time
Make sure to start the desired application you want to analyze before running perfmon.
From the desktop UI, open a command-prompt window and type:
Click “Performance Monitor” to view data in real time.
Right click anywhere in the area highlighted in green below to add the counters you want to view.
Select “Add Counters” as shown below.
By default, perfmon already displays percentage processor time. Select specific counters to display system’s C States, Interrupt Rate, Context Switching Rate and System Call Rate. We are interested mostly in the deepest C state (C3).
Select Deepest C state Counter
Select “% C3 Time.” Click “Add,” then “OK.”
Since we are running perfmon on a mobile platform, make sure to unplug the power cord, otherwise the % C3 time will be zero.
Select Interrupt Rate Counter
Choose “Interrupts/sec.” Click “Add,” then “OK.”
Select Clock Interrupt Rate Counter
Click “Clock Interrupts/sec.” Click “Add,” then “OK.”
Select Wakeup Rate Counter
Click “Idle Break Events/sec.” Click “Add,” then “OK.”
Select Context-Switch Rate Counter
Click “Context Switches/sec.” Click “Add,” then “OK.”
Select System-Call Rate Counter
Click “System Calls/sec.” Click “Add,” then “OK.”
After selecting all necessary counters, the final screen will look like this:
How to Select Counter to View
In this case, we selected the % C3 counter. The other counters were hidden by unchecking them in the “Show” area, highlighted by a green box in the image above. The picture also shows the average value of % C3 time: 99.33%. The value of % C3 time will be interpreted in the section “How to Find Issues.”
Run and Write Data to a File
If you wish not to analyze the data in real time, and instead want to run the test analyze later, before performing the test, take the following steps:
- Create a folder.
- Go to your new folder and create a text file that contains all the necessary counters. Let’s name it “counterlist.txt”. The content of that file should look like this:
"\Processor(_Total)\% Processor Time"
"\Processor(_Total)\% C3 Time"
"\Processor Information(_Total)\Clock Interrupts/sec"
"\Processor Information(_Total)\Idle Break Events/sec"
Note that these above steps need to be done once.
To run and write data to a file, do the following:
- Open a command-prompt window in administrator mode.
- Go to the folder created in the above steps
- At the prompt type:
typeperf -cf counterlist.txt -o datafile.csv
- Run the application you want to check. Make sure to let the application running idle.
- Let it run. Hit Ctrl-C when you want it to stop collecting data. Generally, collecting data from one to two minutes should be sufficient.
- The data will be written into a file called datafile.csv in the current folder.
Typeperf is a command-line tool that comes with Windows*. The .csv file can be opened using Microsoft Excel* should look something like this:
How to Find Issues
The more time the system spends in a deep C-state, the less power it consumes. Microsoft recommends that the deepest C-state residency in idle should be greater than or equal to 99%. From the above file, find the average value of % C3 time. If the value is less than 99% then there are issues. Similarly, find the average values of the other counters you collected. If those values during idle are unusually high (in multiples of three) compared to when the system is idle and not running your application, then there are problems to solve with the application’s power consumption.
Performance monitor (perfmon) is a useful tool that allows users, at a high level, to quickly identify if an application has power issues.