Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Unified Diff: tools/eval_gc_nvp.py

Issue 1348763006: [tools] Add script to analyze GC tracing output (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/eval_gc_nvp.py
diff --git a/tools/eval_gc_nvp.py b/tools/eval_gc_nvp.py
new file mode 100755
index 0000000000000000000000000000000000000000..5c7904e517caca251eb46ca3bea6f929f54c74b5
--- /dev/null
+++ b/tools/eval_gc_nvp.py
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+#
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""This script is used to analyze GCTracer's NVP output."""
+
+from argparse import ArgumentParser
+from gc_nvp_common import split_nvp
+from sys import stdin
+
+class Histogram:
+ def __init__(self, values, granularity):
+ self.values = list(values) # copy over values
+ self.granularity = granularity
+
+ def __str__(self):
+ ret = []
+ values = list(self.values) # copy over values
+ min_value = 0
+ while len(values) > 0:
+ max_value = min_value + self.granularity
+ sub = [x for x in self.values if x >= min_value and x < max_value]
+ ret.append(" [{0},{1}[: {2}".format(
+ str(min_value), str(max_value),len(sub)))
+ min_value += self.granularity
+ values = [x for x in values if x not in sub]
+ return "\n".join(ret)
+
+
+class Category:
+ def __init__(self, key, histogram, granularity):
+ self.key = key
+ self.values = []
+ self.histogram = histogram
+ self.granularity = granularity
+
+ def process_entry(self, entry):
+ if self.key in entry:
+ self.values.append(float(entry[self.key]))
+
+ def __str__(self):
+ ret = [self.key]
+ ret.append(" len: {0}".format(len(self.values)))
+ if len(self.values) > 0:
+ ret.append(" min: {0}".format(min(self.values)))
+ ret.append(" max: {0}".format(max(self.values)))
+ ret.append(" avg: {0}".format(sum(self.values) / len(self.values)))
+ if self.histogram:
+ ret.append(str(Histogram(self.values, self.granularity)))
+ return "\n".join(ret)
+
+
+def main():
+ parser = ArgumentParser(description="Process GCTracer's NVP output")
+ parser.add_argument('keys', metavar='KEY', type=str, nargs='+',
+ help='the keys (names) to process')
+ parser.add_argument('--histogram-granularity', metavar='GRANULARITY',
+ type=int, nargs='?', default=5,
+ help='histogram granularity (default: 5)')
+ feature_parser = parser.add_mutually_exclusive_group(required=False)
+ feature_parser.add_argument('--histogram', dest='histogram',
+ action='store_true',
+ help='print histogram')
+ feature_parser.add_argument('--no-histogram', dest='histogram',
+ action='store_false',
+ help='do not print histogram')
+ parser.set_defaults(histogram=True)
+ args = parser.parse_args()
+
+ categories = [ Category(key, args.histogram, args.histogram_granularity)
+ for key in args.keys ]
+
+ while True:
+ line = stdin.readline()
+ if not line:
+ break
+ obj = split_nvp(line)
+ for category in categories:
+ category.process_entry(obj)
+
+ for category in categories:
+ print(category)
+
+
+if __name__ == '__main__':
+ main()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698