OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 import os | 4 import os |
5 | 5 |
6 from chrome_remote_control import multi_page_benchmark | 6 from chrome_remote_control import multi_page_benchmark |
7 from chrome_remote_control import util | 7 from chrome_remote_control import util |
8 | 8 |
9 class DidNotScrollException(multi_page_benchmark.MeasurementFailure): | 9 class DidNotScrollException(multi_page_benchmark.MeasurementFailure): |
10 def __init__(self): | 10 def __init__(self): |
(...skipping 23 matching lines...) Expand all Loading... | |
34 help='Disable the chrome.gpuBenchmarking extension.') | 34 help='Disable the chrome.gpuBenchmarking extension.') |
35 parser.add_option('--report-all-results', dest='report_all_results', | 35 parser.add_option('--report-all-results', dest='report_all_results', |
36 action='store_true', | 36 action='store_true', |
37 help='Reports all data collected, not just FPS') | 37 help='Reports all data collected, not just FPS') |
38 | 38 |
39 @staticmethod | 39 @staticmethod |
40 def ScrollPageFully(page, tab): | 40 def ScrollPageFully(page, tab): |
41 scroll_js_path = os.path.join(os.path.dirname(__file__), 'scroll.js') | 41 scroll_js_path = os.path.join(os.path.dirname(__file__), 'scroll.js') |
42 scroll_js = open(scroll_js_path, 'r').read() | 42 scroll_js = open(scroll_js_path, 'r').read() |
43 | 43 |
44 tab.browser.platform.StartSurfaceCollector() | |
tonyg
2012/10/19 00:47:19
Move this below Execute(scroll_js) while keeping i
bulach
2012/10/22 15:57:14
Done.
| |
44 # Run scroll test. | 45 # Run scroll test. |
45 tab.runtime.Execute(scroll_js) | 46 tab.runtime.Execute(scroll_js) |
46 | 47 |
47 start_scroll_js = """ | 48 start_scroll_js = """ |
48 window.__renderingStatsDeltas = null; | 49 window.__renderingStatsDeltas = null; |
49 new __ScrollTest(function(rendering_stats_deltas) { | 50 new __ScrollTest(function(rendering_stats_deltas) { |
50 window.__renderingStatsDeltas = rendering_stats_deltas; | 51 window.__renderingStatsDeltas = rendering_stats_deltas; |
51 }).start(element); | 52 }).start(element); |
52 """ | 53 """ |
53 # scrollable_element_function is a function that passes the scrollable | 54 # scrollable_element_function is a function that passes the scrollable |
54 # element on the page to a callback. For example: | 55 # element on the page to a callback. For example: |
55 # function (callback) { | 56 # function (callback) { |
56 # callback(document.getElementById('foo')); | 57 # callback(document.getElementById('foo')); |
57 # } | 58 # } |
58 if hasattr(page, 'scrollable_element_function'): | 59 if hasattr(page, 'scrollable_element_function'): |
59 tab.runtime.Execute('(%s)(function(element) { %s });' % | 60 tab.runtime.Execute('(%s)(function(element) { %s });' % |
60 (page.scrollable_element_function, start_scroll_js)) | 61 (page.scrollable_element_function, start_scroll_js)) |
61 else: | 62 else: |
62 tab.runtime.Execute('(function() { var element = document.body; %s})();' % | 63 tab.runtime.Execute('(function() { var element = document.body; %s})();' % |
63 start_scroll_js) | 64 start_scroll_js) |
64 | 65 |
65 # Poll for scroll benchmark completion. | 66 # Poll for scroll benchmark completion. |
66 util.WaitFor(lambda: tab.runtime.Evaluate( | 67 util.WaitFor(lambda: tab.runtime.Evaluate( |
67 'window.__renderingStatsDeltas'), 60) | 68 'window.__renderingStatsDeltas'), 60) |
68 | 69 |
70 tab.browser.platform.StopSurfaceCollector() | |
71 | |
69 rendering_stats_deltas = tab.runtime.Evaluate( | 72 rendering_stats_deltas = tab.runtime.Evaluate( |
70 'window.__renderingStatsDeltas') | 73 'window.__renderingStatsDeltas') |
71 | 74 |
72 if not (rendering_stats_deltas['numFramesSentToScreen'] > 0): | 75 if not (rendering_stats_deltas['numFramesSentToScreen'] > 0): |
73 raise DidNotScrollException() | 76 raise DidNotScrollException() |
74 return rendering_stats_deltas | 77 return rendering_stats_deltas |
75 | 78 |
76 def CustomizeBrowserOptions(self, options): | 79 def CustomizeBrowserOptions(self, options): |
77 if not options.no_gpu_benchmarking_extension: | 80 if not options.no_gpu_benchmarking_extension: |
78 options.extra_browser_args.append('--enable-gpu-benchmarking') | 81 options.extra_browser_args.append('--enable-gpu-benchmarking') |
79 | 82 |
80 def MeasurePage(self, page, tab, results): | 83 def MeasurePage(self, page, tab, results): |
81 rendering_stats_deltas = self.ScrollPageFully(page, tab) | 84 rendering_stats_deltas = self.ScrollPageFully(page, tab) |
82 CalcScrollResults(rendering_stats_deltas, results) | 85 CalcScrollResults(rendering_stats_deltas, results) |
83 if self.options.report_all_results: | 86 if self.options.report_all_results: |
84 for k, v in rendering_stats_deltas.iteritems(): | 87 for k, v in rendering_stats_deltas.iteritems(): |
85 results.Add(k, '', v) | 88 results.Add(k, '', v) |
OLD | NEW |