diff --git a/ChangeLog b/ChangeLog index 21145e0bb..b41a769db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2007-01-18 Don Allingham + * src/DataViews/Utils.py: add profile function + 2007-01-18 Richard Taylor * src/NameDisplay.py: yet more optimisations for name display. diff --git a/src/Utils.py b/src/Utils.py index e064c8076..04c3a6d2a 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -1076,3 +1076,18 @@ def launch(prog_str,path): os.spawnvpe(os.P_NOWAIT, prog, prog_list, os.environ) +def profile(func): + import hotshot, hotshot.stats + + pr = hotshot.Profile('mystats.profile') + print "Start" + pr.runcall(func) + print "Finished" + pr.close() + print "Loading profile" + stats = hotshot.stats.load('mystats.profile') + print "done" + stats.strip_dirs() + stats.sort_stats('time','calls') + stats.print_stats(100) +