Skip to content

Commit

Permalink
Do what the XXX says and use cProfile instead of hotshot. Gets us pro…
Browse files Browse the repository at this point in the history
…filing under PyPy, too.
  • Loading branch information
gsnedders committed Nov 13, 2011
1 parent 65911f2 commit dd038b3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ def parse():
parseMethod = p.parse

if opts.profile:
#XXX should import cProfile instead and use that
import hotshot
import hotshot.stats
prof = hotshot.Profile('stats.prof')
prof.runcall(parseMethod, f, encoding=encoding)
prof.close()
import cProfile
import pstats
cProfile.runctx("run(parseMethod, f, encoding)", None,
{"run": run,
"parseMethod": parseMethod,
"f": f,
"encoding": encoding},
"stats.prof")
# XXX - We should use a temp file here
stats = hotshot.stats.load('stats.prof')
stats = pstats.Stats('stats.prof')
stats.strip_dirs()
stats.sort_stats('time')
stats.print_stats()
Expand Down

0 comments on commit dd038b3

Please sign in to comment.