Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf80a03

Browse files
committed
Add -p option to invoke Python profiler
1 parent ce0c19c commit bf80a03

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

Tools/compiler/compile.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33

44
from compiler import compile, visitor
55

6-
##import profile
6+
import profile
77

88
def main():
99
VERBOSE = 0
1010
DISPLAY = 0
11+
PROFILE = 0
1112
CONTINUE = 0
12-
opts, args = getopt.getopt(sys.argv[1:], 'vqdc')
13+
opts, args = getopt.getopt(sys.argv[1:], 'vqdcp')
1314
for k, v in opts:
1415
if k == '-v':
1516
VERBOSE = 1
@@ -24,16 +25,21 @@ def main():
2425
DISPLAY = 1
2526
if k == '-c':
2627
CONTINUE = 1
28+
if k == '-p':
29+
PROFILE = 1
2730
if not args:
2831
print "no files to compile"
2932
else:
3033
for filename in args:
3134
if VERBOSE:
3235
print filename
3336
try:
34-
compile(filename, DISPLAY)
35-
## profile.run('compile(%s, %s)' % (`filename`, `DISPLAY`),
36-
## filename + ".prof")
37+
if PROFILE:
38+
profile.run('compile(%s, %s)' % (`filename`, `DISPLAY`),
39+
filename + ".prof")
40+
else:
41+
compile(filename, DISPLAY)
42+
3743
except SyntaxError, err:
3844
print err
3945
print err.lineno

0 commit comments

Comments
 (0)