473,322 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

http://aspn.activestate.com/ASPN/Coo.../Recipe/303339

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

- Andrew
Apr 2 '07 #1
1 2799
Getting the pid:

http://timgolden.me.uk/python/wmi_cookbook.html

List all running processes

import wmi
c = wmi.WMI ()
for process in c.Win32_Process ():
print process.ProcessId, process.Name
List all running notepad processes

import wmi
c = wmi.WMI ()
for process in c.Win32_Process (name="notepad.exe"):
print process.ProcessId, process.Name
Create and then destroy a new notepad process

import wmi
c = wmi.WMI ()
process_id, return_value = c.Win32_Process.Create
(CommandLine="notepad.exe")
for process in c.Win32_Process (ProcessId=process_id):
print process.ProcessId, process.Name

result = process.Terminate ()


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

http://aspn.activestate.com/ASPN/Coo.../Recipe/303339

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
sg*****@ncee.net | 402-438-8958 | http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy
Apr 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: iker.arizmendi | last post by:
Is there any way to get Python to release memory back to the C allocator? I'm currently running a script that goes through the following steps: 1) Creates a very large number of Python objects...
2
by: smitty1e | last post by:
The first print statement does what you'd expect. The second print statement has rather a lot of rat in it. The goal here is to write a function that will return the man page for some command...
12
by: bhunter | last post by:
Hi, I've used subprocess with 2.4 several times to execute a process, wait for it to finish, and then look at its output. Now I want to spawn the process separately, later check to see if it's...
3
by: topazcode | last post by:
I am using the subprocess module to run some shell commands on a Linux system: import subprocess output = subprocess.call('''ssh server1 "uptime"''', shell=True) The above assigns the output...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.