OLD | NEW |
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 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 """Runs Mozilla's Kraken JavaScript benchmark.""" | 5 """Runs Mozilla's Kraken JavaScript benchmark.""" |
6 | 6 |
7 import os | 7 import os |
8 | 8 |
| 9 from measurements import PageTestMeasurement |
9 from metrics import power | 10 from metrics import power |
10 from telemetry import benchmark | 11 from telemetry import benchmark |
11 from telemetry.page import page_set | 12 from telemetry.page import page_set |
12 from telemetry.page import page_test | |
13 from telemetry.value import list_of_scalar_values | 13 from telemetry.value import list_of_scalar_values |
14 from telemetry.value import scalar | 14 from telemetry.value import scalar |
15 | 15 |
16 DESCRIPTIONS = { | 16 DESCRIPTIONS = { |
17 'ai-astar': | 17 'ai-astar': |
18 'This benchmark uses the [A* search algorithm]' | 18 'This benchmark uses the [A* search algorithm]' |
19 '(http://en.wikipedia.org/wiki/A*_search_algorithm) to automatically ' | 19 '(http://en.wikipedia.org/wiki/A*_search_algorithm) to automatically ' |
20 'plot an efficient path between two points, in the presence of ' | 20 'plot an efficient path between two points, in the presence of ' |
21 'obstacles. Adapted from code by [Brian Gringstead]' | 21 'obstacles. Adapted from code by [Brian Gringstead]' |
22 '(http://www.briangrinstead.com/blog/astar-search-algorithm-in-' | 22 '(http://www.briangrinstead.com/blog/astar-search-algorithm-in-' |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 'This benchmark serializes [Tinderbox]' | 58 'This benchmark serializes [Tinderbox]' |
59 '(http://tests.themasta.com/tinderboxpushlog/?tree=Firefox) build ' | 59 '(http://tests.themasta.com/tinderboxpushlog/?tree=Firefox) build ' |
60 'data to [JSON](http://www.json.org).', | 60 'data to [JSON](http://www.json.org).', |
61 } | 61 } |
62 | 62 |
63 | 63 |
64 def _Mean(l): | 64 def _Mean(l): |
65 return float(sum(l)) / len(l) if len(l) > 0 else 0.0 | 65 return float(sum(l)) / len(l) if len(l) > 0 else 0.0 |
66 | 66 |
67 | 67 |
68 class _KrakenMeasurement(page_test.PageTest): | 68 class _KrakenMeasurement(PageTestMeasurement): |
69 def __init__(self): | 69 def __init__(self): |
70 super(_KrakenMeasurement, self).__init__() | 70 super(_KrakenMeasurement, self).__init__() |
71 self._power_metric = None | 71 self._power_metric = None |
72 | 72 |
73 def CustomizeBrowserOptions(self, options): | 73 def CustomizeBrowserOptions(self, options): |
| 74 super(_KrakenMeasurement, self).CustomizeBrowserOptions(options) |
74 power.PowerMetric.CustomizeBrowserOptions(options) | 75 power.PowerMetric.CustomizeBrowserOptions(options) |
75 | 76 |
76 def WillStartBrowser(self, platform): | 77 def WillStartBrowser(self, platform): |
77 self._power_metric = power.PowerMetric(platform) | 78 self._power_metric = power.PowerMetric(platform) |
78 | 79 |
79 def DidNavigateToPage(self, page, tab): | 80 def DidNavigateToPage(self, page, tab): |
80 self._power_metric.Start(page, tab) | 81 self._power_metric.Start(page, tab) |
81 | 82 |
82 def ValidateAndMeasurePage(self, page, tab, results): | 83 def ValidateAndMeasurePage(self, page, tab, results): |
83 tab.WaitForJavaScriptExpression( | 84 tab.WaitForJavaScriptExpression( |
(...skipping 17 matching lines...) Expand all Loading... |
101 description=DESCRIPTIONS.get(key))) | 102 description=DESCRIPTIONS.get(key))) |
102 total += _Mean(result_dict[key]) | 103 total += _Mean(result_dict[key]) |
103 | 104 |
104 # TODO(tonyg/nednguyen): This measurement shouldn't calculate Total. The | 105 # TODO(tonyg/nednguyen): This measurement shouldn't calculate Total. The |
105 # results system should do that for us. | 106 # results system should do that for us. |
106 results.AddValue(scalar.ScalarValue( | 107 results.AddValue(scalar.ScalarValue( |
107 results.current_page, 'Total', 'ms', total, | 108 results.current_page, 'Total', 'ms', total, |
108 description='Total of the means of the results for each type ' | 109 description='Total of the means of the results for each type ' |
109 'of benchmark in [Mozilla\'s Kraken JavaScript benchmark]' | 110 'of benchmark in [Mozilla\'s Kraken JavaScript benchmark]' |
110 '(http://krakenbenchmark.mozilla.org/)')) | 111 '(http://krakenbenchmark.mozilla.org/)')) |
| 112 super(_KrakenMeasurement, self).ValidateAndMeasurePage(page, tab, results) |
111 | 113 |
112 | 114 |
113 class Kraken(benchmark.Benchmark): | 115 class Kraken(benchmark.Benchmark): |
114 """Mozilla's Kraken JavaScript benchmark.""" | 116 """Mozilla's Kraken JavaScript benchmark.""" |
115 test = _KrakenMeasurement | 117 test = _KrakenMeasurement |
116 | 118 |
117 def CreatePageSet(self, options): | 119 def CreatePageSet(self, options): |
118 ps = page_set.PageSet( | 120 ps = page_set.PageSet( |
119 archive_data_file='../page_sets/data/kraken.json', | 121 archive_data_file='../page_sets/data/kraken.json', |
120 file_path=os.path.abspath(__file__)) | 122 file_path=os.path.abspath(__file__)) |
121 ps.AddPageWithDefaultRunNavigate( | 123 ps.AddPageWithDefaultRunNavigate( |
122 'http://krakenbenchmark.mozilla.org/kraken-1.1/driver.html') | 124 'http://krakenbenchmark.mozilla.org/kraken-1.1/driver.html') |
123 return ps | 125 return ps |
OLD | NEW |