Index: tools/eval_gc_nvp.py |
diff --git a/tools/eval_gc_nvp.py b/tools/eval_gc_nvp.py |
index 8a9b8e70728cc58c53970cc4f8184d18a486a543..f18a579391c2f95bdfb2bd2e03ef94b7953acc19 100755 |
--- a/tools/eval_gc_nvp.py |
+++ b/tools/eval_gc_nvp.py |
@@ -85,6 +85,15 @@ class Category: |
if self.histogram: |
self.histogram.add(float(entry[self.key])) |
+ def min(self): |
+ return min(self.values) |
+ |
+ def max(self): |
+ return max(self.values) |
+ |
+ def avg(self): |
+ return sum(self.values) / len(self.values) |
+ |
def __str__(self): |
ret = [self.key] |
ret.append(" len: {0}".format(len(self.values))) |
@@ -96,6 +105,15 @@ class Category: |
ret.append(str(self.histogram)) |
return "\n".join(ret) |
+ def __repr__(self): |
+ return "<Category: {0}>".format(self.key) |
+ |
+ |
+def make_key_func(cmp_metric): |
+ def key_func(a): |
+ return getattr(a, cmp_metric)() |
+ return key_func |
+ |
def main(): |
parser = ArgumentParser(description="Process GCTracer's NVP output") |
@@ -121,6 +139,10 @@ def main(): |
action='store_false', help='do not print histogram') |
parser.set_defaults(histogram=True) |
parser.set_defaults(histogram_omit_empty=False) |
+ parser.add_argument('--rank', metavar='<no|min|max|avg>', |
+ type=str, nargs='?', |
+ default="no", |
+ help="rank keys by metric (default: no)") |
args = parser.parse_args() |
histogram = None |
@@ -143,6 +165,9 @@ def main(): |
for category in categories: |
category.process_entry(obj) |
+ if args.rank != "no": |
+ categories = sorted(categories, key=make_key_func(args.rank), reverse=True) |
+ |
for category in categories: |
print(category) |