Fix a bug in the ``compiler`` package that caused invalid code to be
[python/dscho.git] / Lib / hotshot / stones.py
blobcd4c51d483678ae189a35514c1fa48ac11c62579
1 import errno
2 import hotshot
3 import hotshot.stats
4 import os
5 import sys
6 import test.pystone
8 def main(logfile):
9 p = hotshot.Profile(logfile)
10 benchtime, stones = p.runcall(test.pystone.pystones)
11 p.close()
13 print "Pystone(%s) time for %d passes = %g" % \
14 (test.pystone.__version__, test.pystone.LOOPS, benchtime)
15 print "This machine benchmarks at %g pystones/second" % stones
17 stats = hotshot.stats.load(logfile)
18 stats.strip_dirs()
19 stats.sort_stats('time', 'calls')
20 try:
21 stats.print_stats(20)
22 except IOError, e:
23 if e.errno != errno.EPIPE:
24 raise
26 if __name__ == '__main__':
27 if sys.argv[1:]:
28 main(sys.argv[1])
29 else:
30 import tempfile
31 main(tempfile.NamedTemporaryFile().name)