Tuesday, 15 March 2011

Benchmarking with Python -



Benchmarking with Python -

i looking utilize python scheme benchmark other process's time, info i/o, correctness, etc. interested in accuracy of time. example

start = time() subprocess.call('md5sum', somelist) end = time() print("%d s", end-start)

would sub process add together considerable overhead function beingness called.

edit

well after few quick tests appears best alternative utilize subprocess have noted included stdout/stderr communicate phone call adds 0.002338 s time execution.

use timeit

import timeit timeit.timeit('yourfunction')

update

if in linux, can utilize time command, this:

import subprocess result = subprocess.popen(['time', 'md5sum', somelist], shell = false, stdout = subprocess.pipe, stderr = subprocess.pipe).communicate() print result

python

No comments:

Post a Comment