Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / tools / perf / perf_tools / cheapness_predictor_benchmark.py
bloba0915ebe6784ead9604867043d176c714502fd53
1 # Copyright (c) 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 from perf_tools import cheapness_predictor_measurement
5 from telemetry.page import page_benchmark
7 PREDICTOR_STATS = [
8 {'name': 'picture_pile_count', 'units': ''},
9 {'name': 'predictor_accuracy', 'units': 'percent'},
10 {'name': 'predictor_safely_wrong_count', 'units': ''},
11 {'name': 'predictor_badly_wrong_count', 'units': ''}]
13 class CheapnessPredictorBenchmark(page_benchmark.PageBenchmark):
14 def __init__(self):
15 super(CheapnessPredictorBenchmark, self).__init__('smoothness')
16 self._measurement = None
18 def CustomizeBrowserOptions(self, options):
19 options.AppendExtraBrowserArg('--dom-automation')
20 options.AppendExtraBrowserArg('--enable-prediction-benchmarking')
21 options.AppendExtraBrowserArg('--enable-gpu-benchmarking')
22 options.AppendExtraBrowserArg('--enable-threaded-compositing')
23 options.AppendExtraBrowserArg('--enable-impl-side-painting')
25 def DidNavigateToPage(self, page, tab):
26 self._measurement = \
27 cheapness_predictor_measurement.CheapnessPredictorMeasurement(tab)
28 self._measurement.GatherInitialStats()
30 def DidRunAction(self, page, tab, action):
31 self._measurement.GatherDeltaStats()
33 def CanRunForPage(self, page):
34 return hasattr(page, 'smoothness')
36 def MeasurePage(self, page, tab, results):
37 predictor_stats = self._measurement.stats
39 for stat_to_gather in PREDICTOR_STATS:
40 results.Add(stat_to_gather['name'],
41 stat_to_gather['units'],
42 predictor_stats[stat_to_gather['name']])