Commit ac25f9e2 authored by marja@chromium.org's avatar marja@chromium.org

Telemetry: Add tests which would've caught the memory_benchmark breakage.

BUG=169084
R=nduca
NOTRY=true


Review URL: https://chromiumcodereview.appspot.com/11778100

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176143 0039d316-1c4b-4281-b951-d872f2087c98
parent 663f3fc1
......@@ -103,4 +103,27 @@ class CsvPageBenchmarkResultsTest(unittest.TestCase):
[[self._page_set[0].url, '-', '3'],
[self._page_set[1].url, '4', '-']])
def test_histogram(self):
results = NonPrintingCsvPageBenchmarkResults(csv.writer(self._output),
False)
results.WillMeasurePage(self._page_set[0])
results.Add('a', '',
'{"buckets": [{"low": 1, "high": 2, "count": 1}]}',
data_type='histogram')
results.DidMeasurePage()
results.WillMeasurePage(self._page_set[1])
results.Add('a', '',
'{"buckets": [{"low": 2, "high": 3, "count": 1}]}',
data_type='histogram')
results.DidMeasurePage()
results.PrintSummary('tag')
self.assertEquals(
self.output_header_row,
['url', 'a ()'])
self.assertEquals(
self.output_data_rows,
[[self._page_set[0].url, '1.5'],
[self._page_set[1].url, '2.5']])
......@@ -105,3 +105,32 @@ class PageBenchmarkResultsTest(unittest.TestCase):
self.assertEquals(
benchmark_results.results,
expected)
def test_histogram(self):
page_set = _MakePageSet()
benchmark_results = SummarySavingPageBenchmarkResults()
benchmark_results.WillMeasurePage(page_set.pages[0])
benchmark_results.Add('a', '',
'{"buckets": [{"low": 1, "high": 2, "count": 1}]}',
data_type='histogram')
benchmark_results.DidMeasurePage()
benchmark_results.WillMeasurePage(page_set.pages[1])
benchmark_results.Add('a', '',
'{"buckets": [{"low": 2, "high": 3, "count": 1}]}',
data_type='histogram')
benchmark_results.DidMeasurePage()
benchmark_results.PrintSummary(None)
expected = [
'*HISTOGRAM a_by_url.http___www.foo.com_: ' +
'a_by_url.http___www.foo.com_= ' +
'{"buckets": [{"low": 1, "high": 2, "count": 1}]}\n' +
'Avg a_by_url.http___www.foo.com_: 1.500000',
'*HISTOGRAM a_by_url.http___www.bar.com_: ' +
'a_by_url.http___www.bar.com_= ' +
'{"buckets": [{"low": 2, "high": 3, "count": 1}]}\n' +
'Avg a_by_url.http___www.bar.com_: 2.500000']
self.assertEquals(benchmark_results.results, expected)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment