[diffoscope] 07/08: diffoscope.profiling: Count the number of calls, not just the total time.

Chris Lamb chris at chris-lamb.co.uk
Sun Jan 1 12:48:51 CET 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit b155142a102b8f4fbb389652406a3143a4f2da15
Author: Chris Lamb <lamby at debian.org>
Date:   Sun Jan 1 11:43:19 2017 +0000

    diffoscope.profiling: Count the number of calls, not just the total time.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/profiling.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/diffoscope/profiling.py b/diffoscope/profiling.py
index a83890f..7ec9da8 100644
--- a/diffoscope/profiling.py
+++ b/diffoscope/profiling.py
@@ -38,6 +38,7 @@ class ProfileManager(object):
             self.data = collections.defaultdict(
                 lambda: collections.defaultdict(lambda: {
                     'time': 0.0,
+                    'count': 0,
                 }),
             )
 
@@ -49,6 +50,7 @@ class ProfileManager(object):
             )
 
         self.data[namespace][key]['time'] += time.time() - start
+        self.data[namespace][key]['count'] += 1
 
     def output(self, print):
         title = "Profiling output for: {}".format(' '.join(sys.argv))
@@ -65,4 +67,8 @@ class ProfileManager(object):
             print("\n{}\n{}\n".format(subtitle, "-" * len(subtitle)))
 
             for value, totals in sorted(keys.items(), key=lambda x: x[1]['time'], reverse=True):
-                print("  {:10.3f}s  {}".format(totals['time'], value))
+                print("  {:10.3f}s {:5d} calls    {}".format(
+                    totals['time'],
+                    totals['count'],
+                    value,
+                ))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list