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..55e9f57dc0ce956ee87ce21308f3d16168477637 100755 |
| --- a/tools/ignition/bytecode_dispatches_report.py |
| +++ b/tools/ignition/bytecode_dispatches_report.py |
| @@ -22,11 +22,11 @@ or plot a dispatch heatmap. |
| __HELP_EPILOGUE = """ |
| examples: |
| - # Print the top 10 counters, reading from default filename |
| - # v8.ignition_dispatches_counters.json (default mode) |
| + # Print the hottest bytecode handlers in descending order, reading from |
| + # default filename v8.ignition_dispatches_counters.json (default mode) |
| $ tools/ignition/bytecode_dispatches_report.py |
| - # Print the top 15 counters reading from data.json |
| + # Print the top 15 dispatch counters reading from data.json |
| $ tools/ignition/bytecode_dispatches_report.py -t 15 data.json |
| # Save heatmap to default filename v8.ignition_dispatches_counters.svg |
| @@ -68,6 +68,21 @@ def print_top_counters(dispatches_table, top_count): |
| print "{:>12d}\t{} -> {}".format(counter, source, destination) |
| +def find_top_bytecodes(dispatches_table): |
| + top_bytecodes = [] |
| + for bytecode, counters_from_bytecode in dispatches_table.items(): |
| + top_bytecodes.append((bytecode, sum(counters_from_bytecode.values()))) |
| + top_bytecodes.sort(key=lambda x: x[1], reverse=True) |
| + return top_bytecodes |
| + |
| + |
| +def print_top_bytecodes(dispatches_table): |
| + top_bytecodes = find_top_bytecodes(dispatches_table) |
| + print "Top bytecodes:" |
| + for bytecode, counter in top_bytecodes: |
| + print "{:>12d}\t{}".format(counter, bytecode) |
| + |
| + |
| def build_counters_matrix(dispatches_table): |
| labels = sorted(dispatches_table.keys()) |
| @@ -130,7 +145,7 @@ def parse_command_line(): |
| "--plot_size", "-s", |
| metavar="N", |
| default=30, |
| - help="shorter side, in inches, of the output plot (default 30)" |
| + help="shorter side in inches of the output plot (default 30)" |
| ) |
| command_line_parser.add_argument( |
| "--plot", "-p", |
| @@ -140,13 +155,13 @@ def parse_command_line(): |
| command_line_parser.add_argument( |
| "--interactive", "-i", |
| action="store_true", |
| - help="open an interactive viewer, rather than writing to file" |
| + help="open an interactive viewer, instead of writing to file" |
| ) |
| command_line_parser.add_argument( |
| "--top_count", "-t", |
|
rmcilroy
2016/04/19 10:36:02
This should not be used to specify that you want t
Stefano Sanfilippo
2016/04/19 11:08:33
Done.
|
| metavar="N", |
| type=int, |
| - default=10, |
| + default=0, |
| help="print the top N counters (default 10)" |
| ) |
| command_line_parser.add_argument( |
| @@ -185,8 +200,10 @@ def main(): |
| figure.set_size_inches(program_options.plot_size, |
| program_options.plot_size) |
| pyplot.savefig(program_options.output_filename) |
| - else: |
| + elif program_options.top_count: |
| print_top_counters(dispatches_table, program_options.top_count) |
| + else: |
| + print_top_bytecodes(dispatches_table) |
| if __name__ == "__main__": |