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 json | 7 import json |
8 import os | 8 import os |
9 | 9 |
10 from core import perf_benchmark | 10 from core import perf_benchmark |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 def CustomizeBrowserOptions(self, options): | 79 def CustomizeBrowserOptions(self, options): |
80 power.PowerMetric.CustomizeBrowserOptions(options) | 80 power.PowerMetric.CustomizeBrowserOptions(options) |
81 | 81 |
82 def WillStartBrowser(self, platform): | 82 def WillStartBrowser(self, platform): |
83 self._power_metric = power.PowerMetric(platform) | 83 self._power_metric = power.PowerMetric(platform) |
84 | 84 |
85 def DidNavigateToPage(self, page, tab): | 85 def DidNavigateToPage(self, page, tab): |
86 self._power_metric.Start(page, tab) | 86 self._power_metric.Start(page, tab) |
87 | 87 |
88 def ValidateAndMeasurePage(self, page, tab, results): | 88 def ValidateAndMeasurePage(self, page, tab, results): |
89 tab.WaitForJavaScriptCondition2( | 89 tab.WaitForJavaScriptCondition( |
90 'document.title.indexOf("Results") != -1', timeout=700) | 90 'document.title.indexOf("Results") != -1', timeout=700) |
91 tab.WaitForDocumentReadyStateToBeComplete() | 91 tab.WaitForDocumentReadyStateToBeComplete() |
92 | 92 |
93 self._power_metric.Stop(page, tab) | 93 self._power_metric.Stop(page, tab) |
94 self._power_metric.AddResults(tab, results) | 94 self._power_metric.AddResults(tab, results) |
95 | 95 |
96 result_dict = json.loads(tab.EvaluateJavaScript2(""" | 96 result_dict = json.loads(tab.EvaluateJavaScript(""" |
97 var formElement = document.getElementsByTagName("input")[0]; | 97 var formElement = document.getElementsByTagName("input")[0]; |
98 decodeURIComponent(formElement.value.split("?")[1]); | 98 decodeURIComponent(formElement.value.split("?")[1]); |
99 """)) | 99 """)) |
100 total = 0 | 100 total = 0 |
101 for key in result_dict: | 101 for key in result_dict: |
102 if key == 'v': | 102 if key == 'v': |
103 continue | 103 continue |
104 results.AddValue(list_of_scalar_values.ListOfScalarValues( | 104 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
105 results.current_page, key, 'ms', result_dict[key], important=False, | 105 results.current_page, key, 'ms', result_dict[key], important=False, |
106 description=DESCRIPTIONS.get(key))) | 106 description=DESCRIPTIONS.get(key))) |
(...skipping 25 matching lines...) Expand all Loading... |
132 base_dir=os.path.dirname(os.path.abspath(__file__)), | 132 base_dir=os.path.dirname(os.path.abspath(__file__)), |
133 cloud_storage_bucket=story.PARTNER_BUCKET) | 133 cloud_storage_bucket=story.PARTNER_BUCKET) |
134 ps.AddStory(page_module.Page( | 134 ps.AddStory(page_module.Page( |
135 'http://krakenbenchmark.mozilla.org/kraken-1.1/driver.html', | 135 'http://krakenbenchmark.mozilla.org/kraken-1.1/driver.html', |
136 ps, ps.base_dir)) | 136 ps, ps.base_dir)) |
137 return ps | 137 return ps |
138 | 138 |
139 @classmethod | 139 @classmethod |
140 def ShouldDisable(cls, possible_browser): | 140 def ShouldDisable(cls, possible_browser): |
141 return cls.IsSvelte(possible_browser) # http://crbug.com/624411 | 141 return cls.IsSvelte(possible_browser) # http://crbug.com/624411 |
OLD | NEW |