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

Unified Diff: tools/eval_gc_nvp.py

Issue 1364733002: [tools] Incrementally keep track of GC NVP output (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incrementally keep track of histogram 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
index 5c7904e517caca251eb46ca3bea6f929f54c74b5..047a6dfae751108c874b2eab1410c3fcdb9d6da0 100755
--- a/tools/eval_gc_nvp.py
+++ b/tools/eval_gc_nvp.py
@@ -6,39 +6,57 @@
"""This script is used to analyze GCTracer's NVP output."""
+
from argparse import ArgumentParser
+from copy import deepcopy
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
+ def __init__(self, granularity, fill_empty):
self.granularity = granularity
+ self.histogram = {}
+ self.fill_empty = fill_empty
+
+ def add(self, key):
+ index = int(key / self.granularity)
+ if index not in self.histogram:
+ self.histogram[index] = 0
+ self.histogram[index] += 1
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]
+ keys = self.histogram.keys()
+ keys.sort()
+ last = -self.granularity
+ for key in keys:
+ min_value = key * self.granularity
+ max_value = min_value + self.granularity
+
+ if self.fill_empty:
+ while (last + self.granularity) != min_value:
+ last += self.granularity
+ ret.append(" [{0},{1}[: {2}".format(
+ str(last), str(last + self.granularity), 0))
+
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]
+ str(min_value), str(max_value), self.histogram[key]))
+ last = min_value
return "\n".join(ret)
class Category:
- def __init__(self, key, histogram, granularity):
+ def __init__(self, key, histogram):
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]))
+ if self.histogram:
+ self.histogram.add(float(entry[self.key]))
def __str__(self):
ret = [self.key]
@@ -48,7 +66,7 @@ class Category:
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)))
+ ret.append(str(self.histogram))
return "\n".join(ret)
@@ -59,6 +77,9 @@ def main():
parser.add_argument('--histogram-granularity', metavar='GRANULARITY',
type=int, nargs='?', default=5,
help='histogram granularity (default: 5)')
+ parser.add_argument('--no-histogram-print-empty', dest='histogram_print_empty',
+ action='store_false',
+ help='print empty histogram buckets')
feature_parser = parser.add_mutually_exclusive_group(required=False)
feature_parser.add_argument('--histogram', dest='histogram',
action='store_true',
@@ -67,9 +88,14 @@ def main():
action='store_false',
help='do not print histogram')
parser.set_defaults(histogram=True)
+ parser.set_defaults(histogram_print_empty=True)
args = parser.parse_args()
- categories = [ Category(key, args.histogram, args.histogram_granularity)
+ histogram = None
+ if args.histogram:
+ histogram = Histogram(args.histogram_granularity, args.histogram_print_empty)
+
+ categories = [ Category(key, deepcopy(histogram))
for key in args.keys ]
while True:
« 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