Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | import errno |
2 | import hotshot | |
3 | import hotshot.stats | |
4 | import os | |
5 | import sys | |
6 | import test.pystone | |
7 | ||
8 | def main(logfile): | |
9 | p = hotshot.Profile(logfile) | |
10 | benchtime, stones = p.runcall(test.pystone.pystones) | |
11 | p.close() | |
12 | ||
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 | |
16 | ||
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 | |
25 | ||
26 | if __name__ == '__main__': | |
27 | if sys.argv[1:]: | |
28 | main(sys.argv[1]) | |
29 | else: | |
30 | import tempfile | |
31 | main(tempfile.NamedTemporaryFile().name) |