Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / tools / perf / perf_tools / histogram_unittest.py
blob5f27dadf5007327d67367ffe9300efb9483a887a
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 unittest
7 from perf_tools import histogram as histogram_module
9 class TestHistogram(unittest.TestCase):
10 def testSubtractHistogram(self):
11 baseline_histogram = """{"count": 3, "buckets": [
12 {"low": 1, "high": 2, "count": 1},
13 {"low": 2, "high": 3, "count": 2}]}"""
15 histogram = """{"count": 14, "buckets": [
16 {"low": 1, "high": 2, "count": 1},
17 {"low": 2, "high": 3, "count": 3},
18 {"low": 3, "high": 4, "count": 10}]}"""
20 new_histogram = json.loads(
21 histogram_module.SubtractHistogram(histogram, baseline_histogram))
22 new_buckets = dict()
23 for b in new_histogram['buckets']:
24 new_buckets[b['low']] = b['count']
25 self.assertFalse(1 in new_buckets)
26 self.assertEquals(1, new_buckets[2])
27 self.assertEquals(10, new_buckets[3])