aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r--tools/perf/builtin-stat.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 32b5c003f7fc..61b828236c11 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -74,7 +74,6 @@ static int null_run = 0;
74 74
75static int fd[MAX_NR_CPUS][MAX_COUNTERS]; 75static int fd[MAX_NR_CPUS][MAX_COUNTERS];
76 76
77static u64 event_res[MAX_COUNTERS][3];
78static int event_scaled[MAX_COUNTERS]; 77static int event_scaled[MAX_COUNTERS];
79 78
80struct stats 79struct stats
@@ -179,14 +178,12 @@ static inline int nsec_counter(int counter)
179 */ 178 */
180static void read_counter(int counter) 179static void read_counter(int counter)
181{ 180{
182 u64 *count, single_count[3]; 181 u64 count[3], single_count[3];
183 unsigned int cpu; 182 unsigned int cpu;
184 size_t res, nv; 183 size_t res, nv;
185 int scaled; 184 int scaled;
186 int i; 185 int i;
187 186
188 count = event_res[counter];
189
190 count[0] = count[1] = count[2] = 0; 187 count[0] = count[1] = count[2] = 0;
191 188
192 nv = scale ? 3 : 1; 189 nv = scale ? 3 : 1;
@@ -318,13 +315,16 @@ static int run_perf_stat(int argc __used, const char **argv)
318 return WEXITSTATUS(status); 315 return WEXITSTATUS(status);
319} 316}
320 317
321static void print_noise(double avg, double stddev) 318static void print_noise(int counter, double avg)
322{ 319{
323 if (run_count > 1) 320 if (run_count == 1)
324 fprintf(stderr, " ( +- %7.3f%% )", 100*stddev / avg); 321 return;
322
323 fprintf(stderr, " ( +- %7.3f%% )",
324 100 * stddev_stats(&event_res_stats[counter][0]) / avg);
325} 325}
326 326
327static void nsec_printout(int counter, double avg, double stddev) 327static void nsec_printout(int counter, double avg)
328{ 328{
329 double msecs = avg / 1e6; 329 double msecs = avg / 1e6;
330 330
@@ -334,10 +334,9 @@ static void nsec_printout(int counter, double avg, double stddev)
334 fprintf(stderr, " # %10.3f CPUs ", 334 fprintf(stderr, " # %10.3f CPUs ",
335 avg / avg_stats(&walltime_nsecs_stats)); 335 avg / avg_stats(&walltime_nsecs_stats));
336 } 336 }
337 print_noise(avg, stddev);
338} 337}
339 338
340static void abs_printout(int counter, double avg, double stddev) 339static void abs_printout(int counter, double avg)
341{ 340{
342 fprintf(stderr, " %14.0f %-24s", avg, event_name(counter)); 341 fprintf(stderr, " %14.0f %-24s", avg, event_name(counter));
343 342
@@ -348,7 +347,6 @@ static void abs_printout(int counter, double avg, double stddev)
348 fprintf(stderr, " # %10.3f M/sec", 347 fprintf(stderr, " # %10.3f M/sec",
349 1000.0 * avg / avg_stats(&runtime_nsecs_stats)); 348 1000.0 * avg / avg_stats(&runtime_nsecs_stats));
350 } 349 }
351 print_noise(avg, stddev);
352} 350}
353 351
354/* 352/*
@@ -356,12 +354,9 @@ static void abs_printout(int counter, double avg, double stddev)
356 */ 354 */
357static void print_counter(int counter) 355static void print_counter(int counter)
358{ 356{
359 double avg, stddev; 357 double avg = avg_stats(&event_res_stats[counter][0]);
360 int scaled = event_scaled[counter]; 358 int scaled = event_scaled[counter];
361 359
362 avg = avg_stats(&event_res_stats[counter][0]);
363 stddev = stddev_stats(&event_res_stats[counter][0]);
364
365 if (scaled == -1) { 360 if (scaled == -1) {
366 fprintf(stderr, " %14s %-24s\n", 361 fprintf(stderr, " %14s %-24s\n",
367 "<not counted>", event_name(counter)); 362 "<not counted>", event_name(counter));
@@ -369,9 +364,11 @@ static void print_counter(int counter)
369 } 364 }
370 365
371 if (nsec_counter(counter)) 366 if (nsec_counter(counter))
372 nsec_printout(counter, avg, stddev); 367 nsec_printout(counter, avg);
373 else 368 else
374 abs_printout(counter, avg, stddev); 369 abs_printout(counter, avg);
370
371 print_noise(counter, avg);
375 372
376 if (scaled) { 373 if (scaled) {
377 double avg_enabled, avg_running; 374 double avg_enabled, avg_running;