| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import math | 5 import math |
| 6 import os | 6 import os |
| 7 | 7 |
| 8 from measurements import PageTestMeasurement |
| 8 from metrics import power | 9 from metrics import power |
| 9 from telemetry import benchmark | 10 from telemetry import benchmark |
| 10 from telemetry.page import page_set | 11 from telemetry.page import page_set |
| 11 from telemetry.page import page_test | |
| 12 from telemetry.value import scalar | 12 from telemetry.value import scalar |
| 13 | 13 |
| 14 | 14 |
| 15 class _DromaeoMeasurement(page_test.PageTest): | 15 class _DromaeoMeasurement(PageTestMeasurement): |
| 16 def __init__(self): | 16 def __init__(self): |
| 17 super(_DromaeoMeasurement, self).__init__() | 17 super(_DromaeoMeasurement, self).__init__() |
| 18 self._power_metric = None | 18 self._power_metric = None |
| 19 | 19 |
| 20 def CustomizeBrowserOptions(self, options): | 20 def CustomizeBrowserOptions(self, options): |
| 21 super(_DromaeoMeasurement, self).CustomizeBrowserOptions(options) |
| 21 power.PowerMetric.CustomizeBrowserOptions(options) | 22 power.PowerMetric.CustomizeBrowserOptions(options) |
| 22 | 23 |
| 23 def WillStartBrowser(self, platform): | 24 def WillStartBrowser(self, platform): |
| 24 self._power_metric = power.PowerMetric(platform) | 25 self._power_metric = power.PowerMetric(platform) |
| 25 | 26 |
| 26 def DidNavigateToPage(self, page, tab): | 27 def DidNavigateToPage(self, page, tab): |
| 27 self._power_metric.Start(page, tab) | 28 self._power_metric.Start(page, tab) |
| 28 | 29 |
| 29 def ValidateAndMeasurePage(self, page, tab, results): | 30 def ValidateAndMeasurePage(self, page, tab, results): |
| 30 tab.WaitForJavaScriptExpression( | 31 tab.WaitForJavaScriptExpression( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 86 |
| 86 top_name = data['collection'].split('-', 1)[0] | 87 top_name = data['collection'].split('-', 1)[0] |
| 87 AggregateData(aggregated, top_name, data['mean']) | 88 AggregateData(aggregated, top_name, data['mean']) |
| 88 | 89 |
| 89 collection_name = data['collection'] | 90 collection_name = data['collection'] |
| 90 AggregateData(aggregated, collection_name, data['mean']) | 91 AggregateData(aggregated, collection_name, data['mean']) |
| 91 | 92 |
| 92 for key, value in aggregated.iteritems(): | 93 for key, value in aggregated.iteritems(): |
| 93 AddResult(key, math.exp(value['sum'] / value['count'])) | 94 AddResult(key, math.exp(value['sum'] / value['count'])) |
| 94 | 95 |
| 96 super(_DromaeoMeasurement, self).ValidateAndMeasurePage( |
| 97 page, tab, results) |
| 98 |
| 95 class _DromaeoBenchmark(benchmark.Benchmark): | 99 class _DromaeoBenchmark(benchmark.Benchmark): |
| 96 """A base class for Dromaeo benchmarks.""" | 100 """A base class for Dromaeo benchmarks.""" |
| 97 test = _DromaeoMeasurement | 101 test = _DromaeoMeasurement |
| 98 | 102 |
| 99 def CreatePageSet(self, options): | 103 def CreatePageSet(self, options): |
| 100 """Makes a PageSet for Dromaeo benchmarks.""" | 104 """Makes a PageSet for Dromaeo benchmarks.""" |
| 101 # Subclasses are expected to define class members called query_param and | 105 # Subclasses are expected to define class members called query_param and |
| 102 # tag. | 106 # tag. |
| 103 if not hasattr(self, 'query_param') or not hasattr(self, 'tag'): | 107 if not hasattr(self, 'query_param') or not hasattr(self, 'tag'): |
| 104 raise NotImplementedError('query_param or tag not in Dromaeo benchmark.') | 108 raise NotImplementedError('query_param or tag not in Dromaeo benchmark.') |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 """Dromaeo JSLib traverse prototype JavaScript benchmark""" | 199 """Dromaeo JSLib traverse prototype JavaScript benchmark""" |
| 196 tag = 'jslibtraverseprototype' | 200 tag = 'jslibtraverseprototype' |
| 197 query_param = 'jslib-traverse-prototype' | 201 query_param = 'jslib-traverse-prototype' |
| 198 | 202 |
| 199 | 203 |
| 200 class DromaeoCSSQueryJquery(_DromaeoBenchmark): | 204 class DromaeoCSSQueryJquery(_DromaeoBenchmark): |
| 201 """Dromaeo CSS Query jquery JavaScript benchmark""" | 205 """Dromaeo CSS Query jquery JavaScript benchmark""" |
| 202 tag = 'cssqueryjquery' | 206 tag = 'cssqueryjquery' |
| 203 query_param = 'cssquery-jquery' | 207 query_param = 'cssquery-jquery' |
| 204 | 208 |
| OLD | NEW |