Skip to contentSkip to conversation

perf stat: Don't print bogus data for stalled-cycles

PATCH New Ramkumar Ramachandra 1 participant 1 message Apr 11, 2014 perf events

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 perf stat: Don't print bogus data for stalled-cycles

When the stalled-cycles-frontend event is requested without the cycles event:

  $ perf stat -e stalled-cycles-frontend -- git s
  ## acme...ram/acme

Performance counter stats for 'git s':

         326,947,423      stalled-cycles-frontend   #    0.00% frontend cycles idle

         0.363599976 seconds time elapsed

The 0.00% frontend cycles idle comment in the output is totally bogus and misleading. Omit printing it here, as well as in the stalled-cycles-backend case.

Cc Jiri Olsa <[email protected]>
Cc David Ahern <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/builtin-stat.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
tools/perf/builtin-stat.c +12 -14
index 8b0e1c9..0bd98fa 100644
@@ -797,14 +797,13 @@ static void print_stalled_cycles_frontend(int cpu,
 
 	total = avg_stats(&runtime_cycles_stats[cpu]);
 
-	if (total)
+	if (total) {
 		ratio = avg / total * 100.0;
-
-	color = get_ratio_color(GRC_STALLED_CYCLES_FE, ratio);
-
-	fprintf(output, " #  ");
-	color_fprintf(output, color, "%6.2f%%", ratio);
-	fprintf(output, " frontend cycles idle   ");
+		color = get_ratio_color(GRC_STALLED_CYCLES_FE, ratio);
+		fprintf(output, " #  ");
+		color_fprintf(output, color, "%6.2f%%", ratio);
+		fprintf(output, " frontend cycles idle   ");
+	}
 }
 
 static void print_stalled_cycles_backend(int cpu,
@@ -816,14 +815,13 @@ static void print_stalled_cycles_backend(int cpu,
 
 	total = avg_stats(&runtime_cycles_stats[cpu]);
 
-	if (total)
+	if (total) {
 		ratio = avg / total * 100.0;
-
-	color = get_ratio_color(GRC_STALLED_CYCLES_BE, ratio);
-
-	fprintf(output, " #  ");
-	color_fprintf(output, color, "%6.2f%%", ratio);
-	fprintf(output, " backend  cycles idle   ");
+		color = get_ratio_color(GRC_STALLED_CYCLES_BE, ratio);
+		fprintf(output, " #  ");
+		color_fprintf(output, color, "%6.2f%%", ratio);
+		fprintf(output, " backend  cycles idle   ");
+	}
 }
 
 static void print_branch_misses(int cpu,
Signature · 1 line
1.9.2.667.ge5b74e1