From b24c75398ac37fe04f0eb1365ee71844f476c8ef Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 19 Jan 2007 05:16:41 +0000 Subject: [PATCH] 2007-01-18 Don Allingham * src/DataViews/Utils.py: add profile function svn: r7931 --- gramps2/ChangeLog | 3 +++ gramps2/src/Utils.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 21145e0bb..b41a769db 100644 --- a/gramps2/ChangeLog +++ b/gramps2/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/gramps2/src/Utils.py b/gramps2/src/Utils.py index e064c8076..04c3a6d2a 100644 --- a/gramps2/src/Utils.py +++ b/gramps2/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) +