[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1306439406-18037-3-git-send-email-jim.cromie@gmail.com>
Date: Thu, 26 May 2011 13:50:05 -0600
From: Jim Cromie <jim.cromie@...il.com>
To: mingo@...e.hu
Cc: acme@...stprotocols.net, linux-kernel@...r.kernel.org,
Jim Cromie <jim.cromie@...il.com>
Subject: [PATCH 2/3] perf-stat: fix +- nan% in -Aa runs
without this patch, I get computations like this:
[jimc@...ucho 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@...il.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists