diff options
author | Fred Drake <fdrake@acm.org> | 2002-07-18 19:47:05 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-07-18 19:47:05 (GMT) |
commit | 0d7e68adf20a95d360391f3e6216ed5ad43623f1 (patch) | |
tree | 53f2dc660f5f543d2c7654c219625ff3d9c319c4 /Lib/hotshot/stones.py | |
parent | fbe36082906201210da081d71c6ac7b30f7ef1a2 (diff) | |
download | cpython-0d7e68adf20a95d360391f3e6216ed5ad43623f1.zip cpython-0d7e68adf20a95d360391f3e6216ed5ad43623f1.tar.gz cpython-0d7e68adf20a95d360391f3e6216ed5ad43623f1.tar.bz2 |
Script to run the pystones "benchmark" under HotShot.
Diffstat (limited to 'Lib/hotshot/stones.py')
-rw-r--r-- | Lib/hotshot/stones.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/hotshot/stones.py b/Lib/hotshot/stones.py new file mode 100644 index 0000000..5a029d5 --- /dev/null +++ b/Lib/hotshot/stones.py @@ -0,0 +1,35 @@ +import errno +import hotshot +import hotshot.stats +import os +import sys +import test.pystone + + +if sys.argv[1:]: + logfile = sys.argv[1] + cleanup = 0 +else: + import tempfile + logfile = tempfile.mktemp() + cleanup = 1 + + +p = hotshot.Profile(logfile) +benchtime, stones = p.runcall(test.pystone.pystones) +p.close() + +print "Pystone(%s) time for %d passes = %g" % \ + (test.pystone.__version__, test.pystone.LOOPS, benchtime) +print "This machine benchmarks at %g pystones/second" % stones + +stats = hotshot.stats.load(logfile) +if cleanup: + os.unlink(logfile) +stats.strip_dirs() +stats.sort_stats('time', 'calls') +try: + stats.print_stats(20) +except IOError, e: + if e.errno != errno.EPIPE: + raise |