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 import collections | 4 import collections |
5 import json | 5 import json |
6 import os | 6 import os |
7 | 7 |
8 from core import perf_benchmark | 8 from core import perf_benchmark |
9 | 9 |
10 from telemetry import page as page_module | 10 from telemetry import page as page_module |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 def CustomizeBrowserOptions(self, options): | 84 def CustomizeBrowserOptions(self, options): |
85 power.PowerMetric.CustomizeBrowserOptions(options) | 85 power.PowerMetric.CustomizeBrowserOptions(options) |
86 | 86 |
87 def WillStartBrowser(self, platform): | 87 def WillStartBrowser(self, platform): |
88 self._power_metric = power.PowerMetric(platform) | 88 self._power_metric = power.PowerMetric(platform) |
89 | 89 |
90 def DidNavigateToPage(self, page, tab): | 90 def DidNavigateToPage(self, page, tab): |
91 self._power_metric.Start(page, tab) | 91 self._power_metric.Start(page, tab) |
92 | 92 |
93 def ValidateAndMeasurePage(self, page, tab, results): | 93 def ValidateAndMeasurePage(self, page, tab, results): |
94 tab.WaitForJavaScriptCondition2( | 94 tab.WaitForJavaScriptCondition( |
95 'window.location.pathname.indexOf("results.html") >= 0' | 95 'window.location.pathname.indexOf("results.html") >= 0' |
96 '&& typeof(output) != "undefined"', timeout=300) | 96 '&& typeof(output) != "undefined"', timeout=300) |
97 | 97 |
98 self._power_metric.Stop(page, tab) | 98 self._power_metric.Stop(page, tab) |
99 self._power_metric.AddResults(tab, results) | 99 self._power_metric.AddResults(tab, results) |
100 | 100 |
101 js_results = json.loads(tab.EvaluateJavaScript2('JSON.stringify(output);')) | 101 js_results = json.loads(tab.EvaluateJavaScript('JSON.stringify(output);')) |
102 | 102 |
103 # Below, r is a map of benchmark names to lists of result numbers, | 103 # Below, r is a map of benchmark names to lists of result numbers, |
104 # and totals is a list of totals of result numbers. | 104 # and totals is a list of totals of result numbers. |
105 # js_results is: formatted like this: | 105 # js_results is: formatted like this: |
106 # [ | 106 # [ |
107 # {'3d-cube': v1, '3d-morph': v2, ...}, | 107 # {'3d-cube': v1, '3d-morph': v2, ...}, |
108 # {'3d-cube': v3, '3d-morph': v4, ...}, | 108 # {'3d-cube': v3, '3d-morph': v4, ...}, |
109 # ... | 109 # ... |
110 # ] | 110 # ] |
111 r = collections.defaultdict(list) | 111 r = collections.defaultdict(list) |
(...skipping 26 matching lines...) Expand all Loading... |
138 return 'sunspider' | 138 return 'sunspider' |
139 | 139 |
140 def CreateStorySet(self, options): | 140 def CreateStorySet(self, options): |
141 ps = story.StorySet( | 141 ps = story.StorySet( |
142 archive_data_file='../page_sets/data/sunspider.json', | 142 archive_data_file='../page_sets/data/sunspider.json', |
143 base_dir=os.path.dirname(os.path.abspath(__file__)), | 143 base_dir=os.path.dirname(os.path.abspath(__file__)), |
144 cloud_storage_bucket=story.PARTNER_BUCKET) | 144 cloud_storage_bucket=story.PARTNER_BUCKET) |
145 ps.AddStory(page_module.Page( | 145 ps.AddStory(page_module.Page( |
146 _URL, ps, ps.base_dir, make_javascript_deterministic=False)) | 146 _URL, ps, ps.base_dir, make_javascript_deterministic=False)) |
147 return ps | 147 return ps |
OLD | NEW |