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

Unified Diff: tools/telemetry/telemetry/util.py

Issue 12221137: Telemetry / Memory benchmark fix: Separate histograms for different tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months 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/telemetry/telemetry/util.py
diff --git a/tools/telemetry/telemetry/util.py b/tools/telemetry/telemetry/util.py
index db93bcf79cb22d8c54be83016febb60dae8fd84d..30ef414cf755cfbaf3bdd83efe71b510881b635d 100644
--- a/tools/telemetry/telemetry/util.py
+++ b/tools/telemetry/telemetry/util.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import inspect
+import json
import socket
import time
@@ -66,3 +67,26 @@ def GetAvailableLocalPort():
tmp.close()
return port
+
+def SubtractHistogram(histogram_json, baseline_json):
nduca 2013/02/12 18:33:15 i'd rather this wasn't in telemetry. Histograms ar
marja 2013/02/13 16:09:30 perf_test_helpers.py seems like a logical place, s
+ """Subtracts baseline from a histogram. Both histogram and baseline are json
+ serializations of histograms."""
+ histogram = json.loads(histogram_json)
+ baseline = json.loads(baseline_json)
+
+ baseline_buckets = dict()
+ for b in baseline['buckets']:
+ baseline_buckets[b['low']] = b['count']
+
+ new_buckets = []
+ for b in histogram['buckets']:
+ new_bucket = b
+ low = b['low']
+ if low in baseline_buckets:
+ new_bucket['count'] = b['count'] - baseline_buckets[low]
+ if new_bucket['count']:
+ new_buckets.append(new_bucket)
+ histogram['buckets'] = new_buckets
+ histogram['count'] -= baseline['count']
+
+ return json.dumps(histogram)

Powered by Google App Engine
This is Rietveld 408576698