Skip to content

Commit dd038b3

Browse files
committed
Do what the XXX says and use cProfile instead of hotshot. Gets us profiling under PyPy, too.
1 parent 65911f2 commit dd038b3

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

parse.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,16 @@ def parse():
5858
parseMethod = p.parse
5959

6060
if opts.profile:
61-
#XXX should import cProfile instead and use that
62-
import hotshot
63-
import hotshot.stats
64-
prof = hotshot.Profile('stats.prof')
65-
prof.runcall(parseMethod, f, encoding=encoding)
66-
prof.close()
61+
import cProfile
62+
import pstats
63+
cProfile.runctx("run(parseMethod, f, encoding)", None,
64+
{"run": run,
65+
"parseMethod": parseMethod,
66+
"f": f,
67+
"encoding": encoding},
68+
"stats.prof")
6769
# XXX - We should use a temp file here
68-
stats = hotshot.stats.load('stats.prof')
70+
stats = pstats.Stats('stats.prof')
6971
stats.strip_dirs()
7072
stats.sort_stats('time')
7173
stats.print_stats()

0 commit comments

Comments
 (0)