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

Side by Side 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: Modified as per comments. 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 unified diff | Download patch
« no previous file with comments | « tools/perf/benchmarks/peacekeeper.py ('k') | tools/perf/page_sets/data/peacekeeper_array.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """A collection of statistical utility functions to be used by metrics.""" 5 """A collection of statistical utility functions to be used by metrics."""
6 6
7 import bisect 7 import bisect
8 import math 8 import math
9 9
10 10
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return sorted_values[0] 206 return sorted_values[0]
207 elif percentile >= (n - 0.5) / n: 207 elif percentile >= (n - 0.5) / n:
208 return sorted_values[-1] 208 return sorted_values[-1]
209 else: 209 else:
210 floor_index = int(math.floor(n * percentile - 0.5)) 210 floor_index = int(math.floor(n * percentile - 0.5))
211 floor_value = sorted_values[floor_index] 211 floor_value = sorted_values[floor_index]
212 ceil_value = sorted_values[floor_index+1] 212 ceil_value = sorted_values[floor_index+1]
213 alpha = n * percentile - 0.5 - floor_index 213 alpha = n * percentile - 0.5 - floor_index
214 return floor_value + alpha * (ceil_value - floor_value) 214 return floor_value + alpha * (ceil_value - floor_value)
215 215
216
217 def GeometricMean(values):
218 """Compute a rounded geometric mean from an array of values."""
219 if not values:
220 return None
221 # To avoid infinite value errors, make sure no value is less than 0.001.
222 new_values = []
223 for value in values:
224 if value > 0.001:
225 new_values.append(value)
226 else:
227 new_values.append(0.001)
228 # Compute the sum of the log of the values.
229 log_sum = sum(map(math.log, new_values))
230 # Raise e to that sum over the number of values.
231 mean = math.pow(math.e, (log_sum / len(new_values)))
232 # Return the rounded mean.
233 return int(round(mean))
234
OLDNEW
« no previous file with comments | « tools/perf/benchmarks/peacekeeper.py ('k') | tools/perf/page_sets/data/peacekeeper_array.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698