| OLD | NEW |
| (Empty) |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 import json | |
| 5 import unittest | |
| 6 | |
| 7 from metrics import histogram_util | |
| 8 | |
| 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}]}""" | |
| 14 | |
| 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}]}""" | |
| 19 | |
| 20 new_histogram = json.loads( | |
| 21 histogram_util.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]) | |
| OLD | NEW |