From: Dima Kogan <dima@secretsauce.net>
To: Arnaldo Carvalho de Melo <acme@kernel.org>, linux-kernel@vger.kernel.org
Cc: Dima Kogan <dima@secretsauce.net>
Subject: [PATCH] perf: Util.py add_stats() computes the mean correctly
Date: Tue, 8 Aug 2017 22:31:49 -0700 [thread overview]
Message-ID: <20170809053149.14092-1-dima@secretsauce.net> (raw)
add_stats() is a utility function for perf scripts to accumulate a value, and
keep track of some statistics. The mean is one of the statistics it keeps track
of, but due to a bug, this wasn't being computed properly. This patch makes the
computation correct
Signed-off-by: Dima Kogan <dima@secretsauce.net>
---
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
index 1d95009592eb..3d1f08b8ba19 100644
--- a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
+++ b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
@@ -41,7 +41,7 @@ def add_stats(dict, key, value):
min = value
if value > max:
max = value
- avg = (avg + value) / 2
+ avg = (avg*count + float(value)) / (count + 1)
dict[key] = (min, max, avg, count + 1)
def clear_term():
--
2.11.0
reply other threads:[~2017-08-09 5:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170809053149.14092-1-dima@secretsauce.net \
--to=dima@secretsauce.net \
--cc=acme@kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®