aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-06-13 09:40:35 -0400
committerIngo Molnar <mingo@elte.hu>2009-06-13 09:40:35 -0400
commitef281a196d66b8bc2d067a3704712e5b93691fbc (patch)
tree616534ffbcb866166316b0b987ce5fa142760d31
parent42202dd56c717f173cd0bf2390249e1bf5cf210b (diff)
perf stat: Enable raw data to be printed
If -vv (very verbose) is specified, print out raw data in the following format: $ perf stat -vv -r 3 ./loop_1b_instructions [ perf stat: executing run #1 ... ] [ perf stat: executing run #2 ... ] [ perf stat: executing run #3 ... ] debug: runtime[0]: 235871872 debug: walltime[0]: 236646752 debug: runtime_cycles[0]: 755150182 debug: counter/0[0]: 235871872 debug: counter/1[0]: 235871872 debug: counter/2[0]: 235871872 debug: scaled[0]: 0 debug: counter/0[1]: 2 debug: counter/1[1]: 235870662 debug: counter/2[1]: 235870662 debug: scaled[1]: 0 debug: counter/0[2]: 1 debug: counter/1[2]: 235870437 debug: counter/2[2]: 235870437 debug: scaled[2]: 0 debug: counter/0[3]: 140 debug: counter/1[3]: 235870298 debug: counter/2[3]: 235870298 debug: scaled[3]: 0 debug: counter/0[4]: 755150182 debug: counter/1[4]: 235870145 debug: counter/2[4]: 235870145 debug: scaled[4]: 0 debug: counter/0[5]: 1001411258 debug: counter/1[5]: 235868838 debug: counter/2[5]: 235868838 debug: scaled[5]: 0 debug: counter/0[6]: 27897 debug: counter/1[6]: 235868560 debug: counter/2[6]: 235868560 debug: scaled[6]: 0 debug: counter/0[7]: 2910 debug: counter/1[7]: 235868151 debug: counter/2[7]: 235868151 debug: scaled[7]: 0 debug: runtime[0]: 235980257 debug: walltime[0]: 236770942 debug: runtime_cycles[0]: 755114546 debug: counter/0[0]: 235980257 debug: counter/1[0]: 235980257 debug: counter/2[0]: 235980257 debug: scaled[0]: 0 debug: counter/0[1]: 3 debug: counter/1[1]: 235980049 debug: counter/2[1]: 235980049 debug: scaled[1]: 0 debug: counter/0[2]: 1 debug: counter/1[2]: 235979907 debug: counter/2[2]: 235979907 debug: scaled[2]: 0 debug: counter/0[3]: 135 debug: counter/1[3]: 235979780 debug: counter/2[3]: 235979780 debug: scaled[3]: 0 debug: counter/0[4]: 755114546 debug: counter/1[4]: 235979652 debug: counter/2[4]: 235979652 debug: scaled[4]: 0 debug: counter/0[5]: 1001439771 debug: counter/1[5]: 235979304 debug: counter/2[5]: 235979304 debug: scaled[5]: 0 debug: counter/0[6]: 23723 debug: counter/1[6]: 235979050 debug: counter/2[6]: 235979050 debug: scaled[6]: 0 debug: counter/0[7]: 2213 debug: counter/1[7]: 235978820 debug: counter/2[7]: 235978820 debug: scaled[7]: 0 debug: runtime[0]: 235888002 debug: walltime[0]: 236700533 debug: runtime_cycles[0]: 754881504 debug: counter/0[0]: 235888002 debug: counter/1[0]: 235888002 debug: counter/2[0]: 235888002 debug: scaled[0]: 0 debug: counter/0[1]: 2 debug: counter/1[1]: 235887793 debug: counter/2[1]: 235887793 debug: scaled[1]: 0 debug: counter/0[2]: 1 debug: counter/1[2]: 235887645 debug: counter/2[2]: 235887645 debug: scaled[2]: 0 debug: counter/0[3]: 135 debug: counter/1[3]: 235887499 debug: counter/2[3]: 235887499 debug: scaled[3]: 0 debug: counter/0[4]: 754881504 debug: counter/1[4]: 235887368 debug: counter/2[4]: 235887368 debug: scaled[4]: 0 debug: counter/0[5]: 1001401731 debug: counter/1[5]: 235887024 debug: counter/2[5]: 235887024 debug: scaled[5]: 0 debug: counter/0[6]: 24212 debug: counter/1[6]: 235886786 debug: counter/2[6]: 235886786 debug: scaled[6]: 0 debug: counter/0[7]: 1824 debug: counter/1[7]: 235886560 debug: counter/2[7]: 235886560 debug: scaled[7]: 0 Performance counter stats for '/home/mingo/loop_1b_instructions' (3 runs): 235.913377 task-clock-msecs # 0.997 CPUs ( +- 0.011% ) 2 context-switches # 0.000 M/sec ( +- 0.000% ) 1 CPU-migrations # 0.000 M/sec ( +- 0.000% ) 136 page-faults # 0.001 M/sec ( +- 0.730% ) 755048744 cycles # 3200.534 M/sec ( +- 0.009% ) 1001417586 instructions # 1.326 IPC ( +- 0.001% ) 25277 cache-references # 0.107 M/sec ( +- 3.988% ) 2315 cache-misses # 0.010 M/sec ( +- 9.845% ) 0.236706075 seconds time elapsed. This allows the summary stats to be validated. Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--tools/perf/Makefile2
-rw-r--r--tools/perf/builtin-stat.c46
2 files changed, 30 insertions, 18 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 0cbd5d6874ec..e8346f95fbb0 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -160,7 +160,7 @@ uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
160# CFLAGS and LDFLAGS are for the users to override from the command line. 160# CFLAGS and LDFLAGS are for the users to override from the command line.
161 161
162CFLAGS = -ggdb3 -Wall -Werror -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement -O6 162CFLAGS = -ggdb3 -Wall -Werror -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement -O6
163LDFLAGS = -lpthread -lrt -lelf 163LDFLAGS = -lpthread -lrt -lelf -lm
164ALL_CFLAGS = $(CFLAGS) 164ALL_CFLAGS = $(CFLAGS)
165ALL_LDFLAGS = $(LDFLAGS) 165ALL_LDFLAGS = $(LDFLAGS)
166STRIP ?= strip 166STRIP ?= strip
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 9eb42b1ae784..e5b3c0ff03a9 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -324,9 +324,9 @@ static void print_counter(int counter)
324} 324}
325 325
326/* 326/*
327 * Normalize noise values down to stddev: 327 * normalize_noise noise values down to stddev:
328 */ 328 */
329static void normalize(__u64 *val) 329static void normalize_noise(__u64 *val)
330{ 330{
331 double res; 331 double res;
332 332
@@ -335,6 +335,13 @@ static void normalize(__u64 *val)
335 *val = (__u64)res; 335 *val = (__u64)res;
336} 336}
337 337
338static void update_avg(const char *name, int idx, __u64 *avg, __u64 *val)
339{
340 *avg += *val;
341
342 if (verbose > 1)
343 fprintf(stderr, "debug: %20s[%d]: %Ld\n", name, idx, *val);
344}
338/* 345/*
339 * Calculate the averages and noises: 346 * Calculate the averages and noises:
340 */ 347 */
@@ -342,16 +349,23 @@ static void calc_avg(void)
342{ 349{
343 int i, j; 350 int i, j;
344 351
352 if (verbose > 1)
353 fprintf(stderr, "\n");
354
345 for (i = 0; i < run_count; i++) { 355 for (i = 0; i < run_count; i++) {
346 runtime_nsecs_avg += runtime_nsecs[i]; 356 update_avg("runtime", 0, &runtime_nsecs_avg, runtime_nsecs + i);
347 walltime_nsecs_avg += walltime_nsecs[i]; 357 update_avg("walltime", 0, &walltime_nsecs_avg, walltime_nsecs + i);
348 runtime_cycles_avg += runtime_cycles[i]; 358 update_avg("runtime_cycles", 0, &runtime_cycles_avg, runtime_cycles + i);
349 359
350 for (j = 0; j < nr_counters; j++) { 360 for (j = 0; j < nr_counters; j++) {
351 event_res_avg[j][0] += event_res[i][j][0]; 361 update_avg("counter/0", j,
352 event_res_avg[j][1] += event_res[i][j][1]; 362 event_res_avg[j]+0, event_res[i][j]+0);
353 event_res_avg[j][2] += event_res[i][j][2]; 363 update_avg("counter/1", j,
354 event_scaled_avg[j] += event_scaled[i][j]; 364 event_res_avg[j]+1, event_res[i][j]+1);
365 update_avg("counter/2", j,
366 event_res_avg[j]+2, event_res[i][j]+2);
367 update_avg("scaled", j,
368 event_scaled_avg + j, event_scaled[i]+j);
355 } 369 }
356 } 370 }
357 runtime_nsecs_avg /= run_count; 371 runtime_nsecs_avg /= run_count;
@@ -382,14 +396,14 @@ static void calc_avg(void)
382 } 396 }
383 } 397 }
384 398
385 normalize(&runtime_nsecs_noise); 399 normalize_noise(&runtime_nsecs_noise);
386 normalize(&walltime_nsecs_noise); 400 normalize_noise(&walltime_nsecs_noise);
387 normalize(&runtime_cycles_noise); 401 normalize_noise(&runtime_cycles_noise);
388 402
389 for (j = 0; j < nr_counters; j++) { 403 for (j = 0; j < nr_counters; j++) {
390 normalize(&event_res_noise[j][0]); 404 normalize_noise(&event_res_noise[j][0]);
391 normalize(&event_res_noise[j][1]); 405 normalize_noise(&event_res_noise[j][1]);
392 normalize(&event_res_noise[j][2]); 406 normalize_noise(&event_res_noise[j][2]);
393 } 407 }
394} 408}
395 409
@@ -399,8 +413,6 @@ static void print_stat(int argc, const char **argv)
399 413
400 calc_avg(); 414 calc_avg();
401 415
402 run_idx = 0;
403
404 fflush(stdout); 416 fflush(stdout);
405 417
406 fprintf(stderr, "\n"); 418 fprintf(stderr, "\n");