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

Side by Side Diff: tools/perf/perf_tools/histogram.py

Issue 12221137: Telemetry / Memory benchmark fix: Separate histograms for different tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add error msg if we do nonsensemaking histogram stuff 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/perf/perf_tools/histogram_measurement.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 import json
5 import logging
6
7 def SubtractHistogram(histogram_json, start_histogram_json):
8 """Subtracts a previous histogram from a histogram. Both parameters are json
9 serializations of histograms."""
10 start_histogram = json.loads(start_histogram_json)
11 # It's ok if the start histogram is empty (we had no data, maybe even no
12 # histogram at all, at the start of the test).
13 if 'buckets' not in start_histogram:
14 return histogram_json
15
16 start_histogram_buckets = dict()
17 for b in start_histogram['buckets']:
18 start_histogram_buckets[b['low']] = b['count']
19
20 new_buckets = []
21 histogram = json.loads(histogram_json)
22 for b in histogram['buckets']:
23 new_bucket = b
24 low = b['low']
25 if low in start_histogram_buckets:
26 new_bucket['count'] = b['count'] - start_histogram_buckets[low]
27 if new_bucket['count'] < 0:
28 logging.error('Histogram subtraction error, starting histogram most '
29 'probably invalid.')
30 if new_bucket['count']:
31 new_buckets.append(new_bucket)
32 histogram['buckets'] = new_buckets
33 histogram['count'] -= start_histogram['count']
34
35 return json.dumps(histogram)
OLDNEW
« no previous file with comments | « no previous file | tools/perf/perf_tools/histogram_measurement.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698