pstats for Windows

The Processes screen of Windows Task Manager lists currently running processes on the local computer. The few columns shown by default allow you to quickly identify the processes that consume the most CPU time or memory. You can also add more columns by going to View | Select Columns. But Task Manager has some limitations. It can't show processes running on a remote machine, and neither "Mem Usage" nor "VM Size" are useful counters when a process approaches its virtual memory limit.

My little pstats for Windows program is a simple-to-use process monitoring tool that provides Task Manager "Process list"-like screen even for a remote computer. Since it's written in clear-text VBScript, you can easily add more performance metrics to the code. If you need to identify handle-leaking processes, for instance, just add HandleCount to the code. The following is a screenshot showing only the top four processes. I included all I/O related metrics because I'm always interested in disk I/O (Note: those metrics also lump device and network I/O together).

Process Stats on localhost at 8/19/2004 5:13:16 PM

Click column header once to sort locally. Press F5 to refresh from localhost. More help
PIDNamePPsrPPrvPUsrVMWSRdBtsPSRdOpsPSWrBtsPSWrOpsPSOtBtsPSOtOpsPS
0Idle98.1799.160016384000000
1808IEXPLORE0.290.118.7517866752028635136122364676340471861896533205210653377234472
1568explorer0.260.179.341301504007606272196267261376141701313993560122962039725577
1532mcshield0.160.0412.573741696083394565186824552853983545804812511919838494821587

Download pstats to a file named pstats.hta. When you use Internet Explorer to access that URL, if you're prompted to Enter computer name instead of prompted to Save file, just Cancel and View Source. Then save the source file to your local disk. If you clicked OK, you would get an ActiveX can't create object error. Ignore it and View Source and save the source. You're also encouraged to save this file you're reading, since it has the pstats Help section below. Run the program by launching it from the folder where you saved the pstats.hta file.

How does pstats work? Performance data is collected by WMI (Windows Management Instrumentation). So make sure the target computer has not had this service disabled or stopped. Pstats fetches this data through the Win32_PerfRawData_PerfProc_Process class. The program is written as an HTA (hypertext application) in VBScript. Data is temporarily stored in a comma-delimited file pstats_targetcomputer.csv and pstats uses TDC (tabular data control) to sort them.

pstats Help
See
MSDN Reference for official interpretation of the WMI class Win32_PerfRawData_PerfProc_Process, on which this program is based. I must point out that after I finished this program, I discovered that the statistics are actually cumulative, in spite of the phrase "PerSec" in the I/O stat names. (See my message posted to the Microsoft official newsgroup without an answer.) In order to find the instantaneous CPU or I/O intensive processes, I would need to calculate the differential stats divided by time interval between two consecutive samplings. But currently pstats can at least answer the question such as "Which process uses the most memory?", or "Which process has used the most total CPU time and consumed the most I/O over its lifetime?" (2012 Update Actually, my topio program does exactly that.)

PPsrPercent of cumulative processor time used by this process (sum of PPrv and PUsr)
PPrvPercent of cumulative privileged (i.e. system or kernel) CPU time used by this process
PUsrPercent of cumulative user CPU time (doing real work) used by this process
VMVirtual memory size in bytes, including shared memory, equivalent to Perfmon "Virtual Bytes" counter and can be used to check process virtual memory usage (sample question: Is my java.exe approaching its -mx1024m limit now?). Note that this is not the same as "VM Size" in Task Manager, which shows private memory only, and not as Task Manager "Mem Usage" either (see below).
WSworking set size in bytes (equivalent to "Mem Usage" in Task Manager)
RdBtsPSNumber of bytes read (supposedly but not per second)
RdOpsPSNumber of reads (supposedly but not per second)
WrBtsPSNumber of bytes written (supposedly but not per second)
WrOpsPSNumber of writes (supposedly but not per second)
OtBtsPSNumber of bytes performed by control operations (supposedly but not per second)
OtOpsPSNumber of I/O control operations (supposedly but not per second)

By default, sorting is done on PPsr. You can change it by changing the line

  <PARAM NAME='SortColumn' VALUE='-PPsr'>
in the OBJECT block of the code. When clicking the column header to sort, the sorting direction is hardcoded: all columns will be sorted in descending order except for Name (the only string type), which sorts in ascending order. You can modify the source code to change the sort direction by changing the + or - sign in front of the column name in the function, such as
function PPsr_onclick()
 pstats.Sort = "-PPsr"

To make the program automatically refresh and fetch new data instead of manually pressing F5, uncomment the META tag near the top. This line

<meta http-equiv="refresh" content="5">
will refresh the stats every 5 seconds.

To save a snapshot of the performance data, select all text (^A) and copy (^C) in the pstats window. You cannot View Source and save the source to a file. Alternatively, just look at pstats_computer.csv created on the fly in the current folder.

To my Computer Page