[tools] Add ranking to GC NVP eval script

BUG=

Review URL: https://codereview.chromium.org/1405903003

Cr-Commit-Position: refs/heads/master@{#31292}
This commit is contained in:
mlippautz 2015-10-15 04:37:30 -07:00 committed by Commit bot
parent 4da32d505f
commit 4a2f630fe8

View File

@ -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)