Chromium Code Reviews| Index: tools/ignition/bytecode_dispatches_report.py |
| diff --git a/tools/ignition/bytecode_dispatches_report.py b/tools/ignition/bytecode_dispatches_report.py |
| index 2c04bef600e0336e9cb84f21d928b20eb3eb61eb..bf987b10a2d1f422702b78e0bed6f1fcede88ba3 100755 |
| --- a/tools/ignition/bytecode_dispatches_report.py |
| +++ b/tools/ignition/bytecode_dispatches_report.py |
| @@ -68,6 +68,22 @@ def print_top_counters(dispatches_table, top_count): |
| print "{:>12d}\t{} -> {}".format(counter, source, destination) |
| +def find_top_dispatch_sources(dispatches_table, top_count): |
| + def dispatch_sources_counters_generator(): |
| + for source, counters_from_source in dispatches_table.items(): |
| + yield source, sum(counters_from_source.values()) |
| + |
| + return heapq.nlargest(top_count, dispatch_sources_counters_generator(), |
|
rmcilroy
2016/04/13 08:45:54
I would probably default to printing all the bytec
Stefano Sanfilippo
2016/04/13 10:19:38
Done.
|
| + key=lambda x: x[1]) |
| + |
| + |
| +def print_top_dispatch_sources(dispatches_table, top_count): |
| + top_dispatch_sources = find_top_dispatch_sources(dispatches_table, top_count) |
| + print "Top {} dispatch sources:".format(top_count) |
|
rmcilroy
2016/04/13 08:45:54
Sources is not a good name since it isn't clear wh
Stefano Sanfilippo
2016/04/13 10:19:37
Done.
|
| + for source, counter in top_dispatch_sources: |
| + print "{:>12d}\t{}".format(counter, source) |
| + |
| + |
| def build_counters_matrix(dispatches_table): |
| labels = sorted(dispatches_table.keys()) |
| @@ -186,6 +202,8 @@ def main(): |
| program_options.plot_size) |
| pyplot.savefig(program_options.output_filename) |
| else: |
| + print_top_dispatch_sources(dispatches_table, program_options.top_count) |
|
rmcilroy
2016/04/13 08:45:54
Please make this a separate option (and be the def
Stefano Sanfilippo
2016/04/13 10:19:37
Done.
|
| + print # just a blank line |
| print_top_counters(dispatches_table, program_options.top_count) |