ruby-changes:68851
From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:12:47 +0900 (JST)
Subject: [ruby-changes:68851] a6d0c61c3c (master): Add percentages to exit op counts in --ujit-stats
https://git.ruby-lang.org/ruby.git/commit/?id=a6d0c61c3c From a6d0c61c3c4a9bb117e5c1bf4da02662f58a50a2 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Thu, 28 Jan 2021 22:56:38 -0500 Subject: Add percentages to exit op counts in --ujit-stats --- ujit_iface.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ujit_iface.c b/ujit_iface.c index 39ea11da4f..4fd28ca5b7 100644 --- a/ujit_iface.c +++ b/ujit_iface.c @@ -417,7 +417,6 @@ ujit_disasm(VALUE self, VALUE code, VALUE from) https://github.com/ruby/ruby/blob/trunk/ujit_iface.c#L417 } #endif - #if RUBY_DEBUG // implementation for --ujit-stats @@ -469,12 +468,15 @@ static void https://github.com/ruby/ruby/blob/trunk/ujit_iface.c#L468 print_insn_count_buffer(const struct insn_count *buffer, int how_many, int left_pad) { size_t longest_insn_len = 0; + size_t total_exit_count = 0; + for (int i = 0; i < how_many; i++) { const char *instruction_name = insn_name(buffer[i].insn); size_t len = strlen(instruction_name); if (len > longest_insn_len) { longest_insn_len = len; } + total_exit_count += buffer[i].count; } for (int i = 0; i < how_many; i++) { @@ -483,7 +485,8 @@ print_insn_count_buffer(const struct insn_count *buffer, int how_many, int left_ https://github.com/ruby/ruby/blob/trunk/ujit_iface.c#L485 for (size_t j = 0; j < padding; j++) { fputc(' ', stderr); } - fprintf(stderr, "%s: %10" PRId64 "\n", instruction_name, buffer[i].count); + double percent = 100 * buffer[i].count / (double)total_exit_count; + fprintf(stderr, "%s: %10" PRId64 " (%.1f%%)\n", instruction_name, buffer[i].count, percent); } } @@ -495,15 +498,14 @@ print_ujit_stats(void) https://github.com/ruby/ruby/blob/trunk/ujit_iface.c#L498 const struct insn_count *sorted_exit_ops = sort_insn_count_array(exit_op_count); - double double_ujit_exec_insns_count = rb_ujit_exec_insns_count; double total_insns_count = vm_insns_count + rb_ujit_exec_insns_count; - double ratio = double_ujit_exec_insns_count / total_insns_count; + double ratio = rb_ujit_exec_insns_count / total_insns_count; fprintf(stderr, "vm_insns_count: %10" PRId64 "\n", vm_insns_count); fprintf(stderr, "ujit_exec_insns_count: %10" PRId64 "\n", rb_ujit_exec_insns_count); fprintf(stderr, "ratio_in_ujit: %9.1f%%\n", ratio * 100); fprintf(stderr, "most frequent exit op:\n"); - print_insn_count_buffer(sorted_exit_ops, 5, 4); + print_insn_count_buffer(sorted_exit_ops, 10, 4); } #endif // if RUBY_DEBUG -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/