summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-09-17 18:08:40 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-09-17 18:08:40 (GMT)
commitbf80a033ee76487de30ea272a8c79346d26536ff (patch)
tree4ffa7b4b336d83639fa8685faf739a2d91e3cd34
parentce0c19c4a84f0486fd1b52da735d9ec1e27e9016 (diff)
downloadcpython-bf80a033ee76487de30ea272a8c79346d26536ff.zip
cpython-bf80a033ee76487de30ea272a8c79346d26536ff.tar.gz
cpython-bf80a033ee76487de30ea272a8c79346d26536ff.tar.bz2
Add -p option to invoke Python profiler
-rw-r--r--Tools/compiler/compile.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/Tools/compiler/compile.py b/Tools/compiler/compile.py
index 41dc898..1a843e2 100644
--- a/Tools/compiler/compile.py
+++ b/Tools/compiler/compile.py
@@ -3,13 +3,14 @@ import getopt
from compiler import compile, visitor
-##import profile
+import profile
def main():
VERBOSE = 0
DISPLAY = 0
+ PROFILE = 0
CONTINUE = 0
- opts, args = getopt.getopt(sys.argv[1:], 'vqdc')
+ opts, args = getopt.getopt(sys.argv[1:], 'vqdcp')
for k, v in opts:
if k == '-v':
VERBOSE = 1
@@ -24,6 +25,8 @@ def main():
DISPLAY = 1
if k == '-c':
CONTINUE = 1
+ if k == '-p':
+ PROFILE = 1
if not args:
print "no files to compile"
else:
@@ -31,9 +34,12 @@ def main():
if VERBOSE:
print filename
try:
- compile(filename, DISPLAY)
-## profile.run('compile(%s, %s)' % (`filename`, `DISPLAY`),
-## filename + ".prof")
+ if PROFILE:
+ profile.run('compile(%s, %s)' % (`filename`, `DISPLAY`),
+ filename + ".prof")
+ else:
+ compile(filename, DISPLAY)
+
except SyntaxError, err:
print err
print err.lineno