| 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 time | 5 import time |
| 6 | 6 |
| 7 from measurements import smoothness | 7 from measurements import smoothness |
| 8 from telemetry.page import page_test | 8 from telemetry.page import page_test |
| 9 from telemetry.value import scalar | 9 from telemetry.value import scalar |
| 10 | 10 |
| 11 | 11 |
| 12 class RecordPerArea(page_test.PageTest): | 12 class RecordPerArea(page_test.PageTest): |
| 13 def __init__(self): | 13 def __init__(self, start_wait_time=2): |
| 14 super(RecordPerArea, self).__init__('', True) | 14 super(RecordPerArea, self).__init__('', True) |
| 15 | 15 self._start_wait_time = start_wait_time |
| 16 def AddCommandLineArgs(self, parser): | |
| 17 parser.add_option('--start-wait-time', type='float', | |
| 18 default=2, | |
| 19 help='Wait time before the benchmark is started ' | |
| 20 '(must be long enought to load all content)') | |
| 21 | 16 |
| 22 def CustomizeBrowserOptions(self, options): | 17 def CustomizeBrowserOptions(self, options): |
| 23 smoothness.Smoothness.CustomizeBrowserOptions(options) | 18 smoothness.Smoothness.CustomizeBrowserOptions(options) |
| 24 options.AppendExtraBrowserArgs([ | 19 options.AppendExtraBrowserArgs([ |
| 25 '--enable-impl-side-painting', | 20 '--enable-impl-side-painting', |
| 26 '--enable-threaded-compositing', | 21 '--enable-threaded-compositing', |
| 27 '--enable-gpu-benchmarking' | 22 '--enable-gpu-benchmarking' |
| 28 ]) | 23 ]) |
| 29 | 24 |
| 30 def ValidateAndMeasurePage(self, page, tab, results): | 25 def ValidateAndMeasurePage(self, page, tab, results): |
| 31 # Wait until the page has loaded and come to a somewhat steady state. | 26 # Wait until the page has loaded and come to a somewhat steady state. |
| 32 # Needs to be adjusted for every device (~2 seconds for workstation). | 27 # Needs to be adjusted for every device (~2 seconds for workstation). |
| 33 time.sleep(self.options.start_wait_time) | 28 time.sleep(self._start_wait_time) |
| 34 | 29 |
| 35 # Enqueue benchmark | 30 # Enqueue benchmark |
| 36 tab.ExecuteJavaScript(""" | 31 tab.ExecuteJavaScript(""" |
| 37 window.benchmark_results = {}; | 32 window.benchmark_results = {}; |
| 38 window.benchmark_results.done = false; | 33 window.benchmark_results.done = false; |
| 39 chrome.gpuBenchmarking.runMicroBenchmark( | 34 chrome.gpuBenchmarking.runMicroBenchmark( |
| 40 "picture_record_benchmark", | 35 "picture_record_benchmark", |
| 41 function(value) { | 36 function(value) { |
| 42 window.benchmark_results.done = true; | 37 window.benchmark_results.done = true; |
| 43 window.benchmark_results.results = value; | 38 window.benchmark_results.results = value; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 55 all_data = tab.EvaluateJavaScript('window.benchmark_results.results') | 50 all_data = tab.EvaluateJavaScript('window.benchmark_results.results') |
| 56 for data in all_data: | 51 for data in all_data: |
| 57 width = data['width'] | 52 width = data['width'] |
| 58 height = data['height'] | 53 height = data['height'] |
| 59 area = width * height | 54 area = width * height |
| 60 time_ms = data['time_ms'] | 55 time_ms = data['time_ms'] |
| 61 | 56 |
| 62 results.AddValue(scalar.ScalarValue( | 57 results.AddValue(scalar.ScalarValue( |
| 63 results.current_page, 'area_%07d_%dx%d' % (area, width, height), | 58 results.current_page, 'area_%07d_%dx%d' % (area, width, height), |
| 64 'ms', time_ms)) | 59 'ms', time_ms)) |
| OLD | NEW |