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 metrics import power | 8 from metrics import power |
9 from telemetry import test | 9 from telemetry import benchmark |
10 from telemetry.page import page_measurement | 10 from telemetry.page import page_measurement |
11 from telemetry.page import page_set | 11 from telemetry.page import page_set |
12 | 12 |
13 | 13 |
14 class _DromaeoMeasurement(page_measurement.PageMeasurement): | 14 class _DromaeoMeasurement(page_measurement.PageMeasurement): |
15 def __init__(self): | 15 def __init__(self): |
16 super(_DromaeoMeasurement, self).__init__() | 16 super(_DromaeoMeasurement, self).__init__() |
17 self._power_metric = power.PowerMetric() | 17 self._power_metric = power.PowerMetric() |
18 | 18 |
19 def CustomizeBrowserOptions(self, options): | 19 def CustomizeBrowserOptions(self, options): |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 escaped_top_name = data['collection'].split('-', 1)[0] | 80 escaped_top_name = data['collection'].split('-', 1)[0] |
81 AggregateData(aggregated, escaped_top_name, data['mean']) | 81 AggregateData(aggregated, escaped_top_name, data['mean']) |
82 | 82 |
83 escaped_collection = data['collection'] | 83 escaped_collection = data['collection'] |
84 AggregateData(aggregated, escaped_collection, data['mean']) | 84 AggregateData(aggregated, escaped_collection, data['mean']) |
85 | 85 |
86 for key, value in aggregated.iteritems(): | 86 for key, value in aggregated.iteritems(): |
87 AddResult(key, math.exp(value['sum'] / value['count'])) | 87 AddResult(key, math.exp(value['sum'] / value['count'])) |
88 | 88 |
89 class _DromaeoBenchmark(test.Test): | 89 class _DromaeoBenchmark(benchmark.Benchmark): |
90 """A base class for Dromaeo benchmarks.""" | 90 """A base class for Dromaeo benchmarks.""" |
91 test = _DromaeoMeasurement | 91 test = _DromaeoMeasurement |
92 | 92 |
93 def CreatePageSet(self, options): | 93 def CreatePageSet(self, options): |
94 """Makes a PageSet for Dromaeo benchmarks.""" | 94 """Makes a PageSet for Dromaeo benchmarks.""" |
95 # Subclasses are expected to define class members called query_param and | 95 # Subclasses are expected to define class members called query_param and |
96 # tag. | 96 # tag. |
97 if not hasattr(self, 'query_param') or not hasattr(self, 'tag'): | 97 if not hasattr(self, 'query_param') or not hasattr(self, 'tag'): |
98 raise NotImplementedError('query_param or tag not in Dromaeo benchmark.') | 98 raise NotImplementedError('query_param or tag not in Dromaeo benchmark.') |
99 archive_data_file = '../page_sets/data/dromaeo.%s.json' % self.tag | 99 archive_data_file = '../page_sets/data/dromaeo.%s.json' % self.tag |
100 ps = page_set.PageSet( | 100 ps = page_set.PageSet( |
101 make_javascript_deterministic=False, | 101 make_javascript_deterministic=False, |
102 archive_data_file=archive_data_file, | 102 archive_data_file=archive_data_file, |
103 file_path=os.path.abspath(__file__)) | 103 file_path=os.path.abspath(__file__)) |
104 url = 'http://dromaeo.com?%s' % self.query_param | 104 url = 'http://dromaeo.com?%s' % self.query_param |
105 ps.AddPageWithDefaultRunNavigate(url) | 105 ps.AddPageWithDefaultRunNavigate(url) |
106 return ps | 106 return ps |
107 | 107 |
108 | 108 |
109 class DromaeoDomCoreAttr(_DromaeoBenchmark): | 109 class DromaeoDomCoreAttr(_DromaeoBenchmark): |
110 """Dromaeo DOMCore attr JavaScript benchmark.""" | 110 """Dromaeo DOMCore attr JavaScript benchmark.""" |
111 tag = 'domcoreattr' | 111 tag = 'domcoreattr' |
112 query_param = 'dom-attr' | 112 query_param = 'dom-attr' |
113 | 113 |
114 | 114 |
115 @test.Disabled('xp') # crbug.com/323782 | 115 @benchmark.Disabled('xp') # crbug.com/323782 |
116 class DromaeoDomCoreModify(_DromaeoBenchmark): | 116 class DromaeoDomCoreModify(_DromaeoBenchmark): |
117 """Dromaeo DOMCore modify JavaScript benchmark.""" | 117 """Dromaeo DOMCore modify JavaScript benchmark.""" |
118 tag = 'domcoremodify' | 118 tag = 'domcoremodify' |
119 query_param = 'dom-modify' | 119 query_param = 'dom-modify' |
120 | 120 |
121 | 121 |
122 class DromaeoDomCoreQuery(_DromaeoBenchmark): | 122 class DromaeoDomCoreQuery(_DromaeoBenchmark): |
123 """Dromaeo DOMCore query JavaScript benchmark.""" | 123 """Dromaeo DOMCore query JavaScript benchmark.""" |
124 tag = 'domcorequery' | 124 tag = 'domcorequery' |
125 query_param = 'dom-query' | 125 query_param = 'dom-query' |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 """Dromaeo JSLib traverse prototype JavaScript benchmark""" | 189 """Dromaeo JSLib traverse prototype JavaScript benchmark""" |
190 tag = 'jslibtraverseprototype' | 190 tag = 'jslibtraverseprototype' |
191 query_param = 'jslib-traverse-prototype' | 191 query_param = 'jslib-traverse-prototype' |
192 | 192 |
193 | 193 |
194 class DromaeoCSSQueryJquery(_DromaeoBenchmark): | 194 class DromaeoCSSQueryJquery(_DromaeoBenchmark): |
195 """Dromaeo CSS Query jquery JavaScript benchmark""" | 195 """Dromaeo CSS Query jquery JavaScript benchmark""" |
196 tag = 'cssqueryjquery' | 196 tag = 'cssqueryjquery' |
197 query_param = 'cssquery-jquery' | 197 query_param = 'cssquery-jquery' |
198 | 198 |
OLD | NEW |