| 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 json | 5 import json |
| 6 import math | 6 import math |
| 7 import os | 7 import os |
| 8 | 8 |
| 9 from core import perf_benchmark | 9 from core import perf_benchmark |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 def CustomizeBrowserOptions(self, options): | 26 def CustomizeBrowserOptions(self, options): |
| 27 power.PowerMetric.CustomizeBrowserOptions(options) | 27 power.PowerMetric.CustomizeBrowserOptions(options) |
| 28 | 28 |
| 29 def WillStartBrowser(self, platform): | 29 def WillStartBrowser(self, platform): |
| 30 self._power_metric = power.PowerMetric(platform) | 30 self._power_metric = power.PowerMetric(platform) |
| 31 | 31 |
| 32 def DidNavigateToPage(self, page, tab): | 32 def DidNavigateToPage(self, page, tab): |
| 33 self._power_metric.Start(page, tab) | 33 self._power_metric.Start(page, tab) |
| 34 | 34 |
| 35 def ValidateAndMeasurePage(self, page, tab, results): | 35 def ValidateAndMeasurePage(self, page, tab, results): |
| 36 tab.WaitForJavaScriptCondition2( | 36 tab.WaitForJavaScriptCondition( |
| 37 'window.document.getElementById("pause") &&' + | 37 'window.document.getElementById("pause") &&' + |
| 38 'window.document.getElementById("pause").value == "Run"', | 38 'window.document.getElementById("pause").value == "Run"', |
| 39 timeout=120) | 39 timeout=120) |
| 40 | 40 |
| 41 # Start spying on POST request that will report benchmark results, and | 41 # Start spying on POST request that will report benchmark results, and |
| 42 # intercept result data. | 42 # intercept result data. |
| 43 tab.ExecuteJavaScript2(""" | 43 tab.ExecuteJavaScript(""" |
| 44 (function() { | 44 (function() { |
| 45 var real_jquery_ajax_ = window.jQuery; | 45 var real_jquery_ajax_ = window.jQuery; |
| 46 window.results_ = ""; | 46 window.results_ = ""; |
| 47 window.jQuery.ajax = function(request) { | 47 window.jQuery.ajax = function(request) { |
| 48 if (request.url == "store.php") { | 48 if (request.url == "store.php") { |
| 49 window.results_ = decodeURIComponent(request.data); | 49 window.results_ = decodeURIComponent(request.data); |
| 50 window.results_ = window.results_.substring( | 50 window.results_ = window.results_.substring( |
| 51 window.results_.indexOf("=") + 1, | 51 window.results_.indexOf("=") + 1, |
| 52 window.results_.lastIndexOf("&")); | 52 window.results_.lastIndexOf("&")); |
| 53 real_jquery_ajax_(request); | 53 real_jquery_ajax_(request); |
| 54 } | 54 } |
| 55 }; | 55 }; |
| 56 })();""") | 56 })();""") |
| 57 # Starts benchmark. | 57 # Starts benchmark. |
| 58 tab.ExecuteJavaScript2('window.document.getElementById("pause").click();') | 58 tab.ExecuteJavaScript('window.document.getElementById("pause").click();') |
| 59 | 59 |
| 60 tab.WaitForJavaScriptCondition2('!!window.results_', timeout=600) | 60 tab.WaitForJavaScriptCondition('!!window.results_', timeout=600) |
| 61 | 61 |
| 62 self._power_metric.Stop(page, tab) | 62 self._power_metric.Stop(page, tab) |
| 63 self._power_metric.AddResults(tab, results) | 63 self._power_metric.AddResults(tab, results) |
| 64 | 64 |
| 65 score = json.loads(tab.EvaluateJavaScript2('window.results_ || "[]"')) | 65 score = json.loads(tab.EvaluateJavaScript('window.results_ || "[]"')) |
| 66 | 66 |
| 67 def Escape(k): | 67 def Escape(k): |
| 68 chars = [' ', '.', '-', '/', '(', ')', '*'] | 68 chars = [' ', '.', '-', '/', '(', ')', '*'] |
| 69 for c in chars: | 69 for c in chars: |
| 70 k = k.replace(c, '_') | 70 k = k.replace(c, '_') |
| 71 return k | 71 return k |
| 72 | 72 |
| 73 def AggregateData(container, key, value): | 73 def AggregateData(container, key, value): |
| 74 if key not in container: | 74 if key not in container: |
| 75 container[key] = {'count': 0, 'sum': 0} | 75 container[key] = {'count': 0, 'sum': 0} |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 """Dromaeo CSS Query jquery JavaScript benchmark. | 329 """Dromaeo CSS Query jquery JavaScript benchmark. |
| 330 | 330 |
| 331 Tests traversing a DOM structure using the Prototype JavaScript Library. | 331 Tests traversing a DOM structure using the Prototype JavaScript Library. |
| 332 """ | 332 """ |
| 333 tag = 'cssqueryjquery' | 333 tag = 'cssqueryjquery' |
| 334 query_param = 'cssquery-jquery' | 334 query_param = 'cssquery-jquery' |
| 335 | 335 |
| 336 @classmethod | 336 @classmethod |
| 337 def Name(cls): | 337 def Name(cls): |
| 338 return 'dromaeo.cssqueryjquery' | 338 return 'dromaeo.cssqueryjquery' |
| OLD | NEW |