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

Side by Side Diff: tools/eval_gc_nvp.py

Issue 1858573002: [tools] Filter empty categories in GC eval script (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2015 the V8 project authors. All rights reserved. 3 # Copyright 2015 the V8 project authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """This script is used to analyze GCTracer's NVP output.""" 7 """This script is used to analyze GCTracer's NVP output."""
8 8
9 9
10 from argparse import ArgumentParser 10 from argparse import ArgumentParser
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return min(self.values) 90 return min(self.values)
91 91
92 def max(self): 92 def max(self):
93 return max(self.values) 93 return max(self.values)
94 94
95 def avg(self): 95 def avg(self):
96 if len(self.values) == 0: 96 if len(self.values) == 0:
97 return 0.0 97 return 0.0
98 return sum(self.values) / len(self.values) 98 return sum(self.values) / len(self.values)
99 99
100 def empty(self):
101 return len(self.values) == 0
102
100 def __str__(self): 103 def __str__(self):
101 if self.csv: 104 if self.csv:
102 ret = [self.key] 105 ret = [self.key]
103 ret.append(len(self.values)) 106 ret.append(len(self.values))
104 ret.append(self.min()) 107 ret.append(self.min())
105 ret.append(self.max()) 108 ret.append(self.max())
106 ret.append(self.avg()) 109 ret.append(self.avg())
107 ret = [str(x) for x in ret] 110 ret = [str(x) for x in ret]
108 return ",".join(ret) 111 return ",".join(ret)
109 else: 112 else:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 for key in args.keys ] 175 for key in args.keys ]
173 176
174 while True: 177 while True:
175 line = stdin.readline() 178 line = stdin.readline()
176 if not line: 179 if not line:
177 break 180 break
178 obj = split_nvp(line) 181 obj = split_nvp(line)
179 for category in categories: 182 for category in categories:
180 category.process_entry(obj) 183 category.process_entry(obj)
181 184
185 # Filter out empty categories.
186 categories = [x for x in categories if not x.empty()]
187
182 if args.rank != "no": 188 if args.rank != "no":
183 categories = sorted(categories, key=make_key_func(args.rank), reverse=True) 189 categories = sorted(categories, key=make_key_func(args.rank), reverse=True)
184 190
185 for category in categories: 191 for category in categories:
186 print(category) 192 print(category)
187 193
188 194
189 if __name__ == '__main__': 195 if __name__ == '__main__':
190 main() 196 main()
OLDNEW
« 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