From 032b2ecf4b026d2945659d8de325ad3ef6ad4734 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert Date: Thu, 8 Apr 2021 15:18:18 -0400 Subject: [PATCH] Compute percentage of exits for top-10 exit ops --- yjit_iface.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yjit_iface.c b/yjit_iface.c index 1ac36b8cf2..4116e526d8 100644 --- a/yjit_iface.c +++ b/yjit_iface.c @@ -829,17 +829,21 @@ print_insn_count_buffer(int how_many, int left_pad) // Sort the exit ops by decreasing frequency const struct insn_count *sorted_exit_ops = sort_insn_count_array(exit_op_count); - // Compute the longest instruction name + // Compute the longest instruction name and top10_exit_count size_t longest_insn_len = 0; + size_t top10_exit_count = 0; for (int i = 0; i < how_many; i++) { const char *instruction_name = insn_name(sorted_exit_ops[i].insn); size_t len = strlen(instruction_name); if (len > longest_insn_len) { longest_insn_len = len; } + top10_exit_count += sorted_exit_ops[i].count; } - fprintf(stderr, "most frequent exit op:\n"); + double top10_exit_percent = 100.0 * top10_exit_count / total_exit_count; + + fprintf(stderr, "top-%d most frequent exit ops (%.1f%% of exits):\n", how_many, top10_exit_percent); // Print the top-N most frequent exit counts for (int i = 0; i < how_many; i++) {