diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-09-04 12:23:38 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-09-04 14:27:26 -0400 |
commit | 849abde92bd3314a4894f2b4f70b30c2accf8653 (patch) | |
tree | 10249b655b074635bf2c46f25af0c54c894606c3 /tools/perf | |
parent | 8a02631a470d6f2ccec7bcf79c1058b0d4240bce (diff) |
perf stat: Clean up statistics calculations a bit more
Remove some, now useless, global storage.
Don't calculate the stddev when not needed.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-stat.c | 31 |
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 | ||
75 | static int fd[MAX_NR_CPUS][MAX_COUNTERS]; | 75 | static int fd[MAX_NR_CPUS][MAX_COUNTERS]; |
76 | 76 | ||
77 | static u64 event_res[MAX_COUNTERS][3]; | ||
78 | static int event_scaled[MAX_COUNTERS]; | 77 | static int event_scaled[MAX_COUNTERS]; |
79 | 78 | ||
80 | struct stats | 79 | struct stats |
@@ -179,14 +178,12 @@ static inline int nsec_counter(int counter) | |||
179 | */ | 178 | */ |
180 | static void read_counter(int counter) | 179 | static 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 | ||
321 | static void print_noise(double avg, double stddev) | 318 | static 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 | ||
327 | static void nsec_printout(int counter, double avg, double stddev) | 327 | static 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 | ||
340 | static void abs_printout(int counter, double avg, double stddev) | 339 | static 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 | */ |
357 | static void print_counter(int counter) | 355 | static 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; |