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

Unified Diff: tools/telemetry/telemetry/page_benchmark_results_unittest.py

Issue 12278015: [Telemetry] Reorganize everything. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-add shebangs. 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/page_benchmark_results_unittest.py
diff --git a/tools/telemetry/telemetry/page_benchmark_results_unittest.py b/tools/telemetry/telemetry/page_benchmark_results_unittest.py
deleted file mode 100644
index f2e5ab2f0b9596e6b36c237a644d6e2acc3ab10c..0000000000000000000000000000000000000000
--- a/tools/telemetry/telemetry/page_benchmark_results_unittest.py
+++ /dev/null
@@ -1,136 +0,0 @@
-# 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 os
-import unittest
-
-from telemetry.page_benchmark_results import PageBenchmarkResults
-from telemetry.page_set import PageSet
-from telemetry.perf_tests_helper import PrintPerfResult
-
-
-def _MakePageSet():
- return PageSet.FromDict({
- "description": "hello",
- "archive_path": "foo.wpr",
- "pages": [
- {"url": "http://www.foo.com/"},
- {"url": "http://www.bar.com/"}
- ]
- }, os.path.dirname(__file__))
-
-class NonPrintingPageBenchmarkResults(PageBenchmarkResults):
- def __init__(self):
- super(NonPrintingPageBenchmarkResults, self).__init__()
-
- def _PrintPerfResult(self, *args):
- pass
-
-class SummarySavingPageBenchmarkResults(PageBenchmarkResults):
- def __init__(self):
- super(SummarySavingPageBenchmarkResults, self).__init__()
- self.results = []
-
- def _PrintPerfResult(self, *args):
- res = PrintPerfResult(*args, print_to_stdout=False)
- self.results.append(res)
-
-class PageBenchmarkResultsTest(unittest.TestCase):
- def test_basic(self):
- page_set = _MakePageSet()
-
- benchmark_results = NonPrintingPageBenchmarkResults()
- benchmark_results.WillMeasurePage(page_set.pages[0])
- benchmark_results.Add('a', 'seconds', 3)
- benchmark_results.DidMeasurePage()
-
- benchmark_results.WillMeasurePage(page_set.pages[1])
- benchmark_results.Add('a', 'seconds', 3)
- benchmark_results.DidMeasurePage()
-
- benchmark_results.PrintSummary('trace_tag')
-
- def test_url_is_invalid_value(self):
- page_set = _MakePageSet()
-
- benchmark_results = NonPrintingPageBenchmarkResults()
- benchmark_results.WillMeasurePage(page_set.pages[0])
- self.assertRaises(
- AssertionError,
- lambda: benchmark_results.Add('url', 'string', 'foo'))
-
- def test_unit_change(self):
- page_set = _MakePageSet()
-
- benchmark_results = NonPrintingPageBenchmarkResults()
- benchmark_results.WillMeasurePage(page_set.pages[0])
- benchmark_results.Add('a', 'seconds', 3)
- benchmark_results.DidMeasurePage()
-
- benchmark_results.WillMeasurePage(page_set.pages[1])
- self.assertRaises(
- AssertionError,
- lambda: benchmark_results.Add('a', 'foobgrobbers', 3))
-
- def test_type_change(self):
- page_set = _MakePageSet()
-
- benchmark_results = NonPrintingPageBenchmarkResults()
- benchmark_results.WillMeasurePage(page_set.pages[0])
- benchmark_results.Add('a', 'seconds', 3)
- benchmark_results.DidMeasurePage()
-
- benchmark_results.WillMeasurePage(page_set.pages[1])
- self.assertRaises(
- AssertionError,
- lambda: benchmark_results.Add('a', 'seconds', 3, data_type='histogram'))
-
- def test_basic_summary(self):
- page_set = _MakePageSet()
-
- benchmark_results = SummarySavingPageBenchmarkResults()
- benchmark_results.WillMeasurePage(page_set.pages[0])
- benchmark_results.Add('a', 'seconds', 3)
- benchmark_results.DidMeasurePage()
-
- benchmark_results.WillMeasurePage(page_set.pages[1])
- benchmark_results.Add('a', 'seconds', 7)
- benchmark_results.DidMeasurePage()
-
- benchmark_results.PrintSummary(None)
- expected = ['RESULT a_by_url: http___www.foo.com_= 3 seconds',
- 'RESULT a_by_url: http___www.bar.com_= 7 seconds',
- '*RESULT a: a= [3,7] seconds\nAvg a: 5.000000seconds\n' +
- 'Sd a: 2.828427seconds']
- 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)
« no previous file with comments | « tools/telemetry/telemetry/page_benchmark_results.py ('k') | tools/telemetry/telemetry/page_benchmark_value.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698