Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / lib / python2.4 / hotshot / stones.py
CommitLineData
86530b38
AT
1import errno
2import hotshot
3import hotshot.stats
4import os
5import sys
6import test.pystone
7
8def 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
26if __name__ == '__main__':
27 if sys.argv[1:]:
28 main(sys.argv[1])
29 else:
30 import tempfile
31 main(tempfile.NamedTemporaryFile().name)