Measureing memory used by a subprocess

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew McLean

    Measureing memory used by a subprocess

    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



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

    - Andrew
  • Shane Geiger

    #2
    Re: Measureing memory used by a subprocess

    Getting the pid:





    List all running processes

    import wmi
    c = wmi.WMI ()
    for process in c.Win32_Process ():
    print process.Process Id, process.Name


    List all running notepad processes

    import wmi
    c = wmi.WMI ()
    for process in c.Win32_Process (name="notepad. exe"):
    print process.Process Id, process.Name


    Create and then destroy a new notepad process

    import wmi
    c = wmi.WMI ()
    process_id, return_value = c.Win32_Process .Create
    (CommandLine="n otepad.exe")
    for process in c.Win32_Process (ProcessId=proc ess_id):
    print process.Process Id, process.Name

    result = process.Termina te ()




    Andrew McLean wrote:
    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
    >

    >
    But I don't see any obvious way to get the process id of the spawned
    subprocess.
    >
    - Andrew
    >
    --
    Shane Geiger
    IT Director
    National Council on Economic Education
    sgeiger@ncee.ne t | 402-438-8958 | http://www.ncee.net

    Leading the Campaign for Economic and Financial Literacy


    Comment

    Working...