| 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 import multi_page_benchmark | 6 import multi_page_benchmark |
| 7 import util | 7 import util |
| 8 import chrome_remote_control | 8 import chrome_remote_control |
| 9 | 9 |
| 10 class DidNotScrollException(multi_page_benchmark.MeasurementFailure): | 10 class DidNotScrollException(multi_page_benchmark.MeasurementFailure): |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 float(num_frames_sent_to_screen)) | 22 float(num_frames_sent_to_screen)) |
| 23 | 23 |
| 24 return { | 24 return { |
| 25 "mean_frame_time_ms": util.RoundTo3DecimalPlaces( | 25 "mean_frame_time_ms": util.RoundTo3DecimalPlaces( |
| 26 mean_frame_time_seconds * 1000), | 26 mean_frame_time_seconds * 1000), |
| 27 "dropped_percent": util.RoundTo1DecimalPlace( | 27 "dropped_percent": util.RoundTo1DecimalPlace( |
| 28 dropped_percent * 100) | 28 dropped_percent * 100) |
| 29 } | 29 } |
| 30 | 30 |
| 31 class ScrollingBenchmark(multi_page_benchmark.MultiPageBenchmark): | 31 class ScrollingBenchmark(multi_page_benchmark.MultiPageBenchmark): |
| 32 def __init__(self): |
| 33 super(ScrollingBenchmark, self).__init__() |
| 34 self.use_gpu_bencharking_extension = True |
| 35 |
| 32 def ScrollPageFully(self, tab): | 36 def ScrollPageFully(self, tab): |
| 33 scroll_js_path = os.path.join(os.path.dirname(__file__), 'scroll.js') | 37 scroll_js_path = os.path.join(os.path.dirname(__file__), 'scroll.js') |
| 34 scroll_js = open(scroll_js_path, 'r').read() | 38 scroll_js = open(scroll_js_path, 'r').read() |
| 35 | 39 |
| 36 # Run scroll test. | 40 # Run scroll test. |
| 37 tab.runtime.Execute(scroll_js) | 41 tab.runtime.Execute(scroll_js) |
| 38 tab.runtime.Execute(""" | 42 tab.runtime.Execute(""" |
| 39 window.__scrollTestResult = null; | 43 window.__scrollTestResult = null; |
| 40 new __ScrollTest(function(rendering_stats) { | 44 new __ScrollTest(function(rendering_stats) { |
| 41 window.__scrollTestResult = rendering_stats; | 45 window.__scrollTestResult = rendering_stats; |
| 42 }); | 46 }); |
| 43 """) | 47 """) |
| 44 | 48 |
| 45 # Poll for scroll benchmark completion. | 49 # Poll for scroll benchmark completion. |
| 46 chrome_remote_control.WaitFor( | 50 chrome_remote_control.WaitFor( |
| 47 lambda: tab.runtime.Evaluate('window.__scrollTestResult'), 60) | 51 lambda: tab.runtime.Evaluate('window.__scrollTestResult'), 60) |
| 48 | 52 |
| 49 rendering_stats = tab.runtime.Evaluate('window.__scrollTestResult') | 53 rendering_stats = tab.runtime.Evaluate('window.__scrollTestResult') |
| 50 | 54 |
| 51 if rendering_stats["numFramesSentToScreen"] == 0: | 55 if not (rendering_stats["numFramesSentToScreen"] > 0): |
| 52 raise scrolling_benchmark.DidNotScrollException() | 56 raise DidNotScrollException() |
| 53 return rendering_stats | 57 return rendering_stats |
| 54 | 58 |
| 55 def CustomizeBrowserOptions(self, options): | 59 def CustomizeBrowserOptions(self, options): |
| 56 options.extra_browser_args.append('--enable-gpu-benchmarking') | 60 if self.use_gpu_bencharking_extension: |
| 61 options.extra_browser_args.append('--enable-gpu-benchmarking') |
| 57 | 62 |
| 58 def MeasurePage(self, page, tab): | 63 def MeasurePage(self, page, tab): |
| 59 rendering_stats = self.ScrollPageFully(tab) | 64 rendering_stats = self.ScrollPageFully(tab) |
| 60 return _CalcScrollResults(rendering_stats) | 65 return _CalcScrollResults(rendering_stats) |
| 61 | 66 |
| 62 | 67 |
| 63 def Main(): | 68 def Main(): |
| 64 return multi_page_benchmark.Main(ScrollingBenchmark()) | 69 return multi_page_benchmark.Main(ScrollingBenchmark()) |
| OLD | NEW |