2007-01-18 Don Allingham <don@gramps-project.org>

* src/DataViews/Utils.py: add profile function



svn: r7931
This commit is contained in:
Don Allingham 2007-01-19 05:16:41 +00:00
parent c0f9fcb160
commit b24c75398a
2 changed files with 18 additions and 0 deletions

View File

@ -1,3 +1,6 @@
2007-01-18 Don Allingham <don@gramps-project.org>
* src/DataViews/Utils.py: add profile function
2007-01-18 Richard Taylor <rjt-gramps@thegrindstone.me.uk> 2007-01-18 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/NameDisplay.py: yet more optimisations for name display. * src/NameDisplay.py: yet more optimisations for name display.

View File

@ -1076,3 +1076,18 @@ def launch(prog_str,path):
os.spawnvpe(os.P_NOWAIT, prog, prog_list, os.environ) 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)