0001 import errno 0002 import hotshot 0003 import hotshot.stats 0004 import os 0005 import sys 0006 import test.pystone 0007 0008 def main(logfile): 0009 p = hotshot.Profile(logfile) 0010 benchtime, stones = p.runcall(test.pystone.pystones) 0011 p.close() 0012 0013 print "Pystone(%s) time for %d passes = %g" % \ 0014 (test.pystone.__version__, test.pystone.LOOPS, benchtime) 0015 print "This machine benchmarks at %g pystones/second" % stones 0016 0017 stats = hotshot.stats.load(logfile) 0018 stats.strip_dirs() 0019 stats.sort_stats('time', 'calls') 0020 try: 0021 stats.print_stats(20) 0022 except IOError, e: 0023 if e.errno != errno.EPIPE: 0024 raise 0025 0026 if __name__ == '__main__': 0027 if sys.argv[1:]: 0028 main(sys.argv[1]) 0029 else: 0030 import tempfile 0031 main(tempfile.NamedTemporaryFile().name) 0032
Generated by PyXR 0.9.4