aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-stat.c
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.de.marchi@gmail.com>2009-11-15 09:05:08 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-15 09:25:50 -0500
commit7255fe2a42c612f2b8fe4c347f0a5f0c97d85a46 (patch)
tree188f42ec858fc1caf7a50d8fb92393bd7778d59b /tools/perf/builtin-stat.c
parentd2fb8b4151a92223da6a84006f8f248ebeb6677d (diff)
perf stat: Do not print ratio when task-clock event is not counted
The ratio between the number of events and the time elapsed makes sense only if task-clock event is counted. Otherwise it will be simply a (confusing) # 0.000 M/sec This patch outputs the ratio only if task-clock event is counted. Some test examples of before and after: Before: [lucas@skywalker linux.trees.git]$ sudo perf stat -e branch-misses -a -- sleep 1 Performance counter stats for 'sleep 1': 1367818 branch-misses # 0.000 M/sec 1.001494325 seconds time elapsed After (without task-clock): [lucas@skywalker perf]$ sudo ./perf stat -e branch-misses -a -- sleep 1 Performance counter stats for 'sleep 1': 1135044 branch-misses 1.001370775 seconds time elapsed After (with task-clock): [lucas@skywalker perf]$ sudo ./perf stat -e branch-misses -e task-clock -a -- sleep 1 Performance counter stats for 'sleep 1': 1070111 branch-misses # 0.534 M/sec 2002.730893 task-clock-msecs # 1.999 CPUs 1.001640292 seconds time elapsed Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <20091115140507.GB21561@skywalker.lan> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r--tools/perf/builtin-stat.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index c6df3770b87e..c70d72003557 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -357,7 +357,8 @@ static void abs_printout(int counter, double avg)
357 ratio = avg / total; 357 ratio = avg / total;
358 358
359 fprintf(stderr, " # %10.3f IPC ", ratio); 359 fprintf(stderr, " # %10.3f IPC ", ratio);
360 } else if (MATCH_EVENT(HARDWARE, HW_BRANCH_MISSES, counter)) { 360 } else if (MATCH_EVENT(HARDWARE, HW_BRANCH_MISSES, counter) &&
361 runtime_branches_stats.n != 0) {
361 total = avg_stats(&runtime_branches_stats); 362 total = avg_stats(&runtime_branches_stats);
362 363
363 if (total) 364 if (total)
@@ -365,7 +366,7 @@ static void abs_printout(int counter, double avg)
365 366
366 fprintf(stderr, " # %10.3f %% ", ratio); 367 fprintf(stderr, " # %10.3f %% ", ratio);
367 368
368 } else { 369 } else if (runtime_nsecs_stats.n != 0) {
369 total = avg_stats(&runtime_nsecs_stats); 370 total = avg_stats(&runtime_nsecs_stats);
370 371
371 if (total) 372 if (total)