summaryrefslogtreecommitdiff
path: root/sys/src/cmd/python/Tools/scripts/hotshotmain.py
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2021-06-14 00:00:37 +0000
committerOri Bernstein <ori@eigenstate.org>2021-06-14 00:00:37 +0000
commita73a964e51247ed169d322c725a3a18859f109a3 (patch)
tree3f752d117274d444bda44e85609aeac1acf313f3 /sys/src/cmd/python/Tools/scripts/hotshotmain.py
parente64efe273fcb921a61bf27d33b230c4e64fcd425 (diff)
python, hg: tow outside the environment.
they've served us well, and can ride off into the sunset.
Diffstat (limited to 'sys/src/cmd/python/Tools/scripts/hotshotmain.py')
-rw-r--r--sys/src/cmd/python/Tools/scripts/hotshotmain.py55
1 files changed, 0 insertions, 55 deletions
diff --git a/sys/src/cmd/python/Tools/scripts/hotshotmain.py b/sys/src/cmd/python/Tools/scripts/hotshotmain.py
deleted file mode 100644
index 4f406284b..000000000
--- a/sys/src/cmd/python/Tools/scripts/hotshotmain.py
+++ /dev/null
@@ -1,55 +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
- prof.run("execfile(%r)" % filename)
- 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:]))