Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 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 | 4 |
| 5 from metrics import power | 5 from metrics import power |
| 6 from telemetry.page import page_measurement | 6 from telemetry.page import page_measurement |
| 7 from telemetry.timeline import model | 7 from telemetry.timeline import model |
| 8 | 8 |
| 9 | 9 |
| 10 class ImageDecoding(page_measurement.PageMeasurement): | 10 class ImageDecoding(page_measurement.PageMeasurement): |
| 11 def __init__(self): | 11 def __init__(self): |
| 12 super(ImageDecoding, self).__init__() | 12 super(ImageDecoding, self).__init__() |
| 13 self._power_metric = power.PowerMetric() | 13 self._power_metric = power.PowerMetric() |
| 14 | 14 |
| 15 def CustomizeBrowserOptions(self, options): | 15 def CustomizeBrowserOptions(self, options): |
| 16 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') | 16 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') |
| 17 power.PowerMetric.CustomizeBrowserOptions(options) | 17 power.PowerMetric.CustomizeBrowserOptions(options) |
| 18 | 18 |
| 19 def WillNavigateToPage(self, page, tab): | 19 def WillNavigateToPage(self, page, tab): |
| 20 tab.ExecuteJavaScript(""" | 20 tab.ExecuteJavaScript(""" |
| 21 if (window.chrome && | 21 if (window.chrome && |
| 22 chrome.gpuBenchmarking && | 22 chrome.gpuBenchmarking && |
| 23 chrome.gpuBenchmarking.clearImageCache) { | 23 chrome.gpuBenchmarking.clearImageCache) { |
| 24 chrome.gpuBenchmarking.clearImageCache(); | 24 chrome.gpuBenchmarking.clearImageCache(); |
| 25 } | 25 } |
| 26 """) | 26 """) |
| 27 self._power_metric.Start(page, tab) | 27 self._power_metric.Start(page, tab) |
| 28 # FIXME: bare 'devtools' is for compatibility with older reference versions | 28 # FIXME: bare 'devtools' is for compatibility with older reference versions |
| 29 # only and may eventually be removed. | 29 # only and may eventually be removed. |
| 30 tab.browser.StartTracing( | 30 tab.browser.StartTracing( |
|
ernstm
2014/06/19 22:01:24
Please add a TODO comment to remove the webkit.con
dsinclair
2014/06/19 23:02:51
Done.
| |
| 31 'disabled-by-default-devtools.timeline*,devtools,webkit.console') | 31 'disabled-by-default-devtools.timeline*,' + |
| 32 'devtools,webkit.console,blink.console') | |
| 32 | 33 |
| 33 def StopBrowserAfterPage(self, browser, page): | 34 def StopBrowserAfterPage(self, browser, page): |
| 34 return not browser.tabs[0].ExecuteJavaScript(""" | 35 return not browser.tabs[0].ExecuteJavaScript(""" |
| 35 window.chrome && | 36 window.chrome && |
| 36 chrome.gpuBenchmarking && | 37 chrome.gpuBenchmarking && |
| 37 chrome.gpuBenchmarking.clearImageCache; | 38 chrome.gpuBenchmarking.clearImageCache; |
| 38 """) | 39 """) |
| 39 | 40 |
| 40 def MeasurePage(self, page, tab, results): | 41 def MeasurePage(self, page, tab, results): |
| 41 timeline_data = tab.browser.StopTracing() | 42 timeline_data = tab.browser.StopTracing() |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 61 assert durations, 'Failed to find "Decode Image" trace events.' | 62 assert durations, 'Failed to find "Decode Image" trace events.' |
| 62 | 63 |
| 63 image_decoding_avg = sum(durations) / len(durations) | 64 image_decoding_avg = sum(durations) / len(durations) |
| 64 results.Add('ImageDecoding_avg', 'ms', image_decoding_avg) | 65 results.Add('ImageDecoding_avg', 'ms', image_decoding_avg) |
| 65 results.Add('ImageLoading_avg', 'ms', | 66 results.Add('ImageLoading_avg', 'ms', |
| 66 tab.EvaluateJavaScript('averageLoadingTimeMs()')) | 67 tab.EvaluateJavaScript('averageLoadingTimeMs()')) |
| 67 | 68 |
| 68 def CleanUpAfterPage(self, page, tab): | 69 def CleanUpAfterPage(self, page, tab): |
| 69 if tab.browser.is_tracing_running: | 70 if tab.browser.is_tracing_running: |
| 70 tab.browser.StopTracing() | 71 tab.browser.StopTracing() |
| OLD | NEW |