views:

198

answers:

2

I am currently working on a project where one of our goals is to reduce the total amount of data read from disk. Is there a way to determine the total number of bytes run by a process? I am working with on a C++ application built with Visual Studio 2005, running on Windows XP.

Ideally, I would like some sort of monitor that can print results if I specify a process name. But, if there's some sort of API I can use in my own application, that would be good too.

I know that this must be possible somehow, because I can display the total number of bytes read in the task manager as the process is running, I would like to be able to obtain this number for a process that has already finished.

+1  A: 

You can use GetProcessIOCounters function. This returns total read operations, write operations, other, read bytes, write bytes, and other bytes. The process still needs to be alive for this to work - holding a handle to the process should be sufficient. Alternatively, your process could log this info on exit.

If your goal is to reduce your disk I/O, I recommend you use the Windows Performance Toolkit. This will show you what files you are reading the most data from, which threads are reading the most data, and help give you a bit more of a system wide view as well, in case you are causing disk I/O elsewhere in the system.

Michael
The Windows Performance Toolkit looks great, unfortunately, it requires windows vista, and I am still on XP
Moe
A: 

SysInternals's ProcMon will give you all I/O's of a process, including call stack. Their FileMon tool might be useful too.

MSalters
...and if you just want the high-level counts, in-box taskmgr.exe does the job too :) Just make sure to show additional (optional) columns and select the appropriate fields for read I/O requests.
Reuben
@Reuben - thanks, if you'll notice, I mentioned that in the question, but I want to be able to know without having to watch the task manager, and I want something that will persist.
Moe