diff options
author | Fred Drake <fdrake@acm.org> | 2007-10-11 18:01:43 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2007-10-11 18:01:43 (GMT) |
commit | 0e474a801ac6e01a24b900183ef101962148f317 (patch) | |
tree | 18376be3413a5cd6ebf2bf1a8d091022adf0d9aa /Tools | |
parent | b62e8a8062ff81f0f5d80b25aa0fb6b2457c721c (diff) | |
download | cpython-0e474a801ac6e01a24b900183ef101962148f317.zip cpython-0e474a801ac6e01a24b900183ef101962148f317.tar.gz cpython-0e474a801ac6e01a24b900183ef101962148f317.tar.bz2 |
remove hotshot profiler from Py3k
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/scripts/hotshotmain.py | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/Tools/scripts/hotshotmain.py b/Tools/scripts/hotshotmain.py deleted file mode 100644 index 7e39d98..0000000 --- a/Tools/scripts/hotshotmain.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# -*- coding: iso-8859-1 -*- - -""" -Run a Python script under hotshot's control. - -Adapted from a posting on python-dev by Walter Dörwald - -usage %prog [ %prog args ] filename [ filename args ] - -Any arguments after the filename are used as sys.argv for the filename. -""" - -import sys -import optparse -import os -import hotshot -import hotshot.stats - -PROFILE = "hotshot.prof" - -def run_hotshot(filename, profile, args): - prof = hotshot.Profile(profile) - sys.path.insert(0, os.path.dirname(filename)) - sys.argv = [filename] + args - fp = open(filename) - try: - script = fp.read() - finally: - fp.close() - prof.run("exec(%r)" % script) - prof.close() - stats = hotshot.stats.load(profile) - stats.sort_stats("time", "calls") - - # print_stats uses unadorned print statements, so the only way - # to force output to stderr is to reassign sys.stdout temporarily - save_stdout = sys.stdout - sys.stdout = sys.stderr - stats.print_stats() - sys.stdout = save_stdout - - return 0 - -def main(args): - parser = optparse.OptionParser(__doc__) - parser.disable_interspersed_args() - parser.add_option("-p", "--profile", action="store", default=PROFILE, - dest="profile", help='Specify profile file to use') - (options, args) = parser.parse_args(args) - - if len(args) == 0: - parser.print_help("missing script to execute") - return 1 - - filename = args[0] - return run_hotshot(filename, options.profile, args[1:]) - -if __name__ == "__main__": - sys.exit(main(sys.argv[1:])) |