diff options
-rw-r--r-- | tools/perf/Makefile | 2 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 46 |
2 files changed, 30 insertions, 18 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 0cbd5d6874e..e8346f95fbb 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') # CFLAGS and LDFLAGS are for the users to override from the command line. CFLAGS = -ggdb3 -Wall -Werror -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement -O6 -LDFLAGS = -lpthread -lrt -lelf +LDFLAGS = -lpthread -lrt -lelf -lm ALL_CFLAGS = $(CFLAGS) ALL_LDFLAGS = $(LDFLAGS) STRIP ?= strip diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 9eb42b1ae78..e5b3c0ff03a 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -324,9 +324,9 @@ static void print_counter(int counter) } /* - * Normalize noise values down to stddev: + * normalize_noise noise values down to stddev: */ -static void normalize(__u64 *val) +static void normalize_noise(__u64 *val) { double res; @@ -335,6 +335,13 @@ static void normalize(__u64 *val) *val = (__u64)res; } +static void update_avg(const char *name, int idx, __u64 *avg, __u64 *val) +{ + *avg += *val; + + if (verbose > 1) + fprintf(stderr, "debug: %20s[%d]: %Ld\n", name, idx, *val); +} /* * Calculate the averages and noises: */ @@ -342,16 +349,23 @@ static void calc_avg(void) { int i, j; + if (verbose > 1) + fprintf(stderr, "\n"); + for (i = 0; i < run_count; i++) { - runtime_nsecs_avg += runtime_nsecs[i]; - walltime_nsecs_avg += walltime_nsecs[i]; - runtime_cycles_avg += runtime_cycles[i]; + update_avg("runtime", 0, &runtime_nsecs_avg, runtime_nsecs + i); + update_avg("walltime", 0, &walltime_nsecs_avg, walltime_nsecs + i); + update_avg("runtime_cycles", 0, &runtime_cycles_avg, runtime_cycles + i); for (j = 0; j < nr_counters; j++) { - event_res_avg[j][0] += event_res[i][j][0]; - event_res_avg[j][1] += event_res[i][j][1]; - event_res_avg[j][2] += event_res[i][j][2]; - event_scaled_avg[j] += event_scaled[i][j]; + update_avg("counter/0", j, + event_res_avg[j]+0, event_res[i][j]+0); + update_avg("counter/1", j, + event_res_avg[j]+1, event_res[i][j]+1); + update_avg("counter/2", j, + event_res_avg[j]+2, event_res[i][j]+2); + update_avg("scaled", j, + event_scaled_avg + j, event_scaled[i]+j); } } runtime_nsecs_avg /= run_count; @@ -382,14 +396,14 @@ static void calc_avg(void) } } - normalize(&runtime_nsecs_noise); - normalize(&walltime_nsecs_noise); - normalize(&runtime_cycles_noise); + normalize_noise(&runtime_nsecs_noise); + normalize_noise(&walltime_nsecs_noise); + normalize_noise(&runtime_cycles_noise); for (j = 0; j < nr_counters; j++) { - normalize(&event_res_noise[j][0]); - normalize(&event_res_noise[j][1]); - normalize(&event_res_noise[j][2]); + normalize_noise(&event_res_noise[j][0]); + normalize_noise(&event_res_noise[j][1]); + normalize_noise(&event_res_noise[j][2]); } } @@ -399,8 +413,6 @@ static void print_stat(int argc, const char **argv) calc_avg(); - run_idx = 0; - fflush(stdout); fprintf(stderr, "\n"); |