| Index: tools/telemetry/telemetry/util_unittest.py
|
| diff --git a/tools/telemetry/telemetry/util_unittest.py b/tools/telemetry/telemetry/util_unittest.py
|
| index 5d144e38059ac325913fe1931b92812ceb2c23ca..3704470b21cdd76d562f2d5a077ba5c06f688438 100644
|
| --- a/tools/telemetry/telemetry/util_unittest.py
|
| +++ b/tools/telemetry/telemetry/util_unittest.py
|
| @@ -1,6 +1,7 @@
|
| # Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
| +import json
|
| import unittest
|
|
|
| from telemetry import util
|
| @@ -16,3 +17,22 @@ class TestWait(unittest.TestCase):
|
| def test():
|
| return False
|
| self.assertRaises(util.TimeoutException, lambda: util.WaitFor(test, 0.1))
|
| +
|
| + def testSubtractHistogram(self):
|
| + baseline_histogram = """{"count": 3, "buckets": [
|
| +{"low": 1, "high": 2, "count": 1},
|
| +{"low": 2, "high": 3, "count": 2}]}"""
|
| +
|
| + histogram = """{"count": 14, "buckets": [
|
| +{"low": 1, "high": 2, "count": 1},
|
| +{"low": 2, "high": 3, "count": 3},
|
| +{"low": 3, "high": 4, "count": 10}]}"""
|
| +
|
| + new_histogram = json.loads(
|
| + util.SubtractHistogram(histogram, baseline_histogram))
|
| + new_buckets = dict()
|
| + for b in new_histogram['buckets']:
|
| + new_buckets[b['low']] = b['count']
|
| + self.assertFalse(1 in new_buckets)
|
| + self.assertEquals(1, new_buckets[2])
|
| + self.assertEquals(10, new_buckets[3])
|
|
|