[diffoscope] 06/08: diffoscope.profiling: Add extra namespacing to data collection.
Chris Lamb
chris at chris-lamb.co.uk
Sun Jan 1 12:48:48 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 293e019157e021064eb33200e10968baca7ecc68
Author: Chris Lamb <lamby at debian.org>
Date: Sun Jan 1 11:43:19 2017 +0000
diffoscope.profiling: Add extra namespacing to data collection.
Signed-off-by: Chris Lamb <lamby at debian.org>
---
diffoscope/profiling.py | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/diffoscope/profiling.py b/diffoscope/profiling.py
index 9b2f2fe..a83890f 100644
--- a/diffoscope/profiling.py
+++ b/diffoscope/profiling.py
@@ -36,7 +36,9 @@ class ProfileManager(object):
if not self._singleton:
self.data = collections.defaultdict(
- lambda: collections.defaultdict(float),
+ lambda: collections.defaultdict(lambda: {
+ 'time': 0.0,
+ }),
)
def increment(self, start, namespace, key):
@@ -46,7 +48,7 @@ class ProfileManager(object):
key.__class__.__name__,
)
- self.data[namespace][key] += time.time() - start
+ self.data[namespace][key]['time'] += time.time() - start
def output(self, print):
title = "Profiling output for: {}".format(' '.join(sys.argv))
@@ -55,12 +57,12 @@ class ProfileManager(object):
print("=" * len(title))
for namespace, keys in sorted(self.data.items(), key=lambda x: x[0]):
- subtitle = "{} (total: {:.3f}s)".format(
+ subtitle = "{} (total time: {:.3f}s)".format(
namespace,
- sum(keys.values()),
+ sum(x['time'] for x in keys.values()),
)
print("\n{}\n{}\n".format(subtitle, "-" * len(subtitle)))
- for value, total in sorted(keys.items(), key=lambda x: x[1], reverse=True):
- print(" {:10.3f}s {}".format(total, value))
+ for value, totals in sorted(keys.items(), key=lambda x: x[1]['time'], reverse=True):
+ print(" {:10.3f}s {}".format(totals['time'], 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