lkml.org 
[lkml]   [2011]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/3] perf-stat: fix +- nan% in -Aa runs
Date
without this patch, I get computations like this:

[jimc@groucho perf]$ sudo ./perf stat -r3 -Aa perl -e '$i++ for 1..100000'

Performance counter stats for 'perl -e $i++ for 1..100000' (3 runs):

CPU0 12.391883 task-clock-msecs # 0.966 CPUs ( +- -nan% )
CPU1 12.446571 task-clock-msecs # 0.970 CPUs ( +- -nan% )
CPU2 12.408014 task-clock-msecs # 0.967 CPUs ( +- -nan% )
CPU3 12.422264 task-clock-msecs # 0.968 CPUs ( +- -nan% )

I couldnt see anything wrong in the caller, so fixed it in stddev_stats()

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
tools/perf/builtin-stat.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 71bbf72..c59d199 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -151,8 +151,13 @@ static double avg_stats(struct stats *stats)
*/
static double stddev_stats(struct stats *stats)
{
- double variance = stats->M2 / (stats->n - 1);
- double variance_mean = variance / stats->n;
+ double variance, variance_mean;
+
+ if (!stats->n)
+ return 0.0;
+
+ variance = stats->M2 / (stats->n - 1);
+ variance_mean = variance / stats->n;

return sqrt(variance_mean);
}
--
1.7.4.4


\
 
 \ /
  Last update: 2011-05-26 21:53    [W:0.055 / U:4.944 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site