Index: build/android/pylib/perf_tests_helper.py |
diff --git a/build/android/pylib/perf_tests_helper.py b/build/android/pylib/perf_tests_helper.py |
index 44397c01058f8d9e310e5aea3c7872fa00621d54..872d2019d1f9e62c958e3c7814feea49487046b4 100644 |
--- a/build/android/pylib/perf_tests_helper.py |
+++ b/build/android/pylib/perf_tests_helper.py |
@@ -65,6 +65,28 @@ def _MeanAndStdDevFromList(values): |
value = values[0] |
return value, avg, sd |
+def SubtractHistogram(histogram_json, start_histogram_json): |
marja
2013/02/14 13:06:53
And I moved this one away now.
|
+ """Subtracts a previous histogram from a histogram. Both parameters are json |
+ serializations of histograms.""" |
+ histogram = json.loads(histogram_json) |
+ start_histogram = json.loads(start_histogram_json) |
+ |
+ start_histogram_buckets = dict() |
+ for b in start_histogram['buckets']: |
+ start_histogram_buckets[b['low']] = b['count'] |
+ |
+ new_buckets = [] |
+ for b in histogram['buckets']: |
+ new_bucket = b |
+ low = b['low'] |
+ if low in start_histogram_buckets: |
+ new_bucket['count'] = b['count'] - start_histogram_buckets[low] |
+ if new_bucket['count']: |
+ new_buckets.append(new_bucket) |
+ histogram['buckets'] = new_buckets |
+ histogram['count'] -= start_histogram['count'] |
+ |
+ return json.dumps(histogram) |
def PrintPerfResult(measurement, trace, values, units, result_type='default', |
print_to_stdout=True): |