Measureing memory used by a subprocess

Andrew McLean andrew-news at andros.org.uk
Sun Apr 1 20:12:53 EDT 2007


I want to script the benchmarking of some compression algorithms on a 
Windows box. The algorithms are all embodied in command line 
executables, such as gzip and bzip2. I would like to measure three things:

1. size of compressed file
2. elapsed time (clock or preferably CPU)
3. memory used

The first is straightforward, as is measuring elapsed clock time. But 
how would I get the CPU time used by a sub-process or the memory used?

I'm guessing that the Windows Performance Counters may be relevant, see 
the recipe

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303339

But I don't see any obvious way to get the process id of the spawned 
subprocess.

- Andrew



More information about the Python-list mailing list