Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158311
b: refs/heads/master
c: 63d40de
h: refs/heads/master
i:
  158309: 1d22417
  158307: 94e3020
  158303: 0809c0f
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Sep 4, 2009
1 parent f9fcb11 commit 809c8cb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9e9772c458d50dabdb5327821da3803254638cd1
refs/heads/master: 63d40deb2e7c64ed55943d49f078e09fc4b64b54
25 changes: 19 additions & 6 deletions trunk/tools/perf/builtin-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static int null_run = 0;
static int fd[MAX_NR_CPUS][MAX_COUNTERS];

static u64 event_res[MAX_COUNTERS][3];
static u64 event_scaled[MAX_COUNTERS];
static int event_scaled[MAX_COUNTERS];

struct stats
{
Expand All @@ -97,17 +97,31 @@ static double avg_stats(struct stats *stats)
}

/*
* stddev = sqrt(1/N (\Sum n_i^2) - avg(n)^2)
* http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
*
* (\Sum n_i^2) - ((\Sum n_i)^2)/n
* s^2 -------------------------------
* n - 1
*
* http://en.wikipedia.org/wiki/Stddev
*
* The std dev of the mean is related to the std dev by:
*
* s
* s_mean = -------
* sqrt(n)
*
*/
static double stddev_stats(struct stats *stats)
{
double avg = stats->sum / run_count;
double variance = (stats->sum_sq - stats->sum*avg)/(run_count - 1);
double variance_mean = variance / run_count;

return sqrt(stats->sum_sq/run_count - avg*avg);
return sqrt(variance_mean);
}

struct stats event_res_stats[MAX_COUNTERS][3];
struct stats event_scaled_stats[MAX_COUNTERS];
struct stats runtime_nsecs_stats;
struct stats walltime_nsecs_stats;
struct stats runtime_cycles_stats;
Expand Down Expand Up @@ -343,11 +357,10 @@ static void abs_printout(int counter, double avg, double stddev)
static void print_counter(int counter)
{
double avg, stddev;
int scaled;
int scaled = event_scaled[counter];

avg = avg_stats(&event_res_stats[counter][0]);
stddev = stddev_stats(&event_res_stats[counter][0]);
scaled = avg_stats(&event_scaled_stats[counter]);

if (scaled == -1) {
fprintf(stderr, " %14s %-24s\n",
Expand Down

0 comments on commit 809c8cb

Please sign in to comment.