| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 """ | 4 """ |
| 5 Benchmarks in this file is created for the purpose of testing telemetry | 5 Benchmarks in this file is created for the purpose of testing telemetry |
| 6 integration with perf dashboard and bisect bot. The number they produce aren't | 6 integration with perf dashboard and bisect bot. The number they produce aren't |
| 7 meant to represent any actual performance data of the browser. | 7 meant to represent any actual performance data of the browser. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import random | 10 import random |
| 11 | 11 |
| 12 from core import perf_benchmark | 12 from core import perf_benchmark |
| 13 | 13 |
| 14 from telemetry.value import scalar | 14 from telemetry.value import scalar |
| 15 from telemetry.page import page_test | 15 from telemetry.page import page_test |
| 16 | 16 |
| 17 import page_sets | 17 from page_sets import dummy_story_set |
| 18 | 18 |
| 19 | 19 |
| 20 class _DummyTest(page_test.PageTest): | 20 class _DummyTest(page_test.PageTest): |
| 21 def __init__(self, avg, std): | 21 def __init__(self, avg, std): |
| 22 super(_DummyTest, self).__init__() | 22 super(_DummyTest, self).__init__() |
| 23 self._avg = avg | 23 self._avg = avg |
| 24 self._std = std | 24 self._std = std |
| 25 | 25 |
| 26 def ValidateAndMeasurePage(self, page, tab, results): | 26 def ValidateAndMeasurePage(self, page, tab, results): |
| 27 results.AddValue(scalar.ScalarValue( | 27 results.AddValue(scalar.ScalarValue( |
| 28 page=page, | 28 page=page, |
| 29 name='gaussian-value', units='ms', | 29 name='gaussian-value', units='ms', |
| 30 value=random.gauss(self._avg, self._std), | 30 value=random.gauss(self._avg, self._std), |
| 31 description=('Random number that follows the Gaussian distribution ' | 31 description=('Random number that follows the Gaussian distribution ' |
| 32 'with mean=%s and std=%s' % (self._avg, self._std)))) | 32 'with mean=%s and std=%s' % (self._avg, self._std)))) |
| 33 | 33 |
| 34 | 34 |
| 35 class _DummyBenchmark(perf_benchmark.PerfBenchmark): | 35 class _DummyBenchmark(perf_benchmark.PerfBenchmark): |
| 36 page_set = page_sets.DummyStorySet | 36 page_set = dummy_story_set.DummyStorySet |
| 37 | 37 |
| 38 | 38 |
| 39 class DummyBenchmarkOne(_DummyBenchmark): | 39 class DummyBenchmarkOne(_DummyBenchmark): |
| 40 """ A low noise benchmark with mean=100 & std=1. """ | 40 """ A low noise benchmark with mean=100 & std=1. """ |
| 41 | 41 |
| 42 def CreatePageTest(self, options): | 42 def CreatePageTest(self, options): |
| 43 return _DummyTest(100, 1) | 43 return _DummyTest(100, 1) |
| 44 | 44 |
| 45 @classmethod | 45 @classmethod |
| 46 def Name(cls): | 46 def Name(cls): |
| 47 return 'dummy_benchmark.stable_benchmark_1' | 47 return 'dummy_benchmark.stable_benchmark_1' |
| 48 | 48 |
| 49 | 49 |
| 50 class DummyBenchmarkTwo(_DummyBenchmark): | 50 class DummyBenchmarkTwo(_DummyBenchmark): |
| 51 """ A noisy benchmark with mean=50 & std=20. """ | 51 """ A noisy benchmark with mean=50 & std=20. """ |
| 52 | 52 |
| 53 def CreatePageTest(self, options): | 53 def CreatePageTest(self, options): |
| 54 return _DummyTest(50, 20) | 54 return _DummyTest(50, 20) |
| 55 | 55 |
| 56 @classmethod | 56 @classmethod |
| 57 def Name(cls): | 57 def Name(cls): |
| 58 return 'dummy_benchmark.noisy_benchmark_1' | 58 return 'dummy_benchmark.noisy_benchmark_1' |
| 59 |
| 60 def CreateStorySet(self, options): |
| 61 del options # unused |
| 62 story_set = dummy_story_set.DummyStorySet() |
| 63 story_set.AddStory(dummy_story_set.BrokenDummyPage(story_set)) |
| 64 return story_set |
| OLD | NEW |