Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: tools/perf/metrics/statistics.py

Issue 55233007: [Telemetry]: Add PeaceKeeper Benchmark suite(Render, DOM, String and Array tests). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update test-info.json Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/perf/metrics/statistics.py
diff --git a/tools/perf/metrics/statistics.py b/tools/perf/metrics/statistics.py
index 80350fbf54b41bf42bdbf3909b5781722bd56f4a..36bb74ece8e27f99f6c91da01e861b5c556dce8b 100644
--- a/tools/perf/metrics/statistics.py
+++ b/tools/perf/metrics/statistics.py
@@ -213,3 +213,22 @@ def Percentile(values, percentile):
alpha = n * percentile - 0.5 - floor_index
return floor_value + alpha * (ceil_value - floor_value)
+
+def GeometricMean(values):
+ """Compute a rounded geometric mean from an array of values."""
+ if not values:
+ return None
+ # To avoid infinite value errors, make sure no value is less than 0.001.
+ new_values = []
+ for value in values:
+ if value > 0.001:
+ new_values.append(value)
+ else:
+ new_values.append(0.001)
+ # Compute the sum of the log of the values.
+ log_sum = sum(map(math.log, new_values))
+ # Raise e to that sum over the number of values.
+ mean = math.pow(math.e, (log_sum / len(new_values)))
+ # Return the rounded mean.
+ return int(round(mean))
+

Powered by Google App Engine
This is Rietveld 408576698