From ffe4f3c0d109dc53e1b3448ac457052107f34a84 Mon Sep 17 00:00:00 2001 From: David Ahern Date: Fri, 2 Aug 2013 14:05:40 -0600 Subject: perf stats: Add max and min stats Need an initialization function to set min to -1 to differentiate from an actual min of 0. Signed-off-by: David Ahern Reviewed-by: Xiao Guangrong Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Runzhen Wang Cc: Xiao Guangrong Link: http://lkml.kernel.org/r/1375473947-64285-3-git-send-email-dsahern@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/stat.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools/perf/util/stat.c') diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 7c59c28afcc5..6506b3dfb605 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -10,6 +10,12 @@ void update_stats(struct stats *stats, u64 val) delta = val - stats->mean; stats->mean += delta / stats->n; stats->M2 += delta*(val - stats->mean); + + if (val > stats->max) + stats->max = val; + + if (val < stats->min) + stats->min = val; } double avg_stats(struct stats *stats) -- cgit v1.2.3