| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 telemetry.page import page_test | 5 from telemetry.page import page_test |
| 6 from telemetry.timeline import model | 6 from telemetry.timeline import model |
| 7 from telemetry.timeline import tracing_config | 7 from telemetry.timeline import tracing_config |
| 8 from telemetry.value import scalar | 8 from telemetry.value import scalar |
| 9 | 9 |
| 10 | 10 |
| 11 class DrawProperties(page_test.PageTest): | 11 class DrawProperties(page_test.PageTest): |
| 12 | 12 |
| 13 def __init__(self): | 13 def __init__(self): |
| 14 super(DrawProperties, self).__init__() | 14 super(DrawProperties, self).__init__() |
| 15 | 15 |
| 16 def CustomizeBrowserOptions(self, options): | 16 def CustomizeBrowserOptions(self, options): |
| 17 options.AppendExtraBrowserArgs([ | 17 options.AppendExtraBrowserArgs([ |
| 18 '--enable-prefer-compositing-to-lcd-text', | 18 '--enable-prefer-compositing-to-lcd-text', |
| 19 ]) | 19 ]) |
| 20 | 20 |
| 21 def WillNavigateToPage(self, page, tab): | 21 def WillNavigateToPage(self, page, tab): |
| 22 del page # unused |
| 22 config = tracing_config.TracingConfig() | 23 config = tracing_config.TracingConfig() |
| 23 config.tracing_category_filter.AddDisabledByDefault( | 24 config.tracing_category_filter.AddDisabledByDefault( |
| 24 'disabled-by-default-cc.debug.cdp-perf') | 25 'disabled-by-default-cc.debug.cdp-perf') |
| 25 config.enable_chrome_trace = True | 26 config.enable_chrome_trace = True |
| 26 tab.browser.platform.tracing_controller.StartTracing(config) | 27 tab.browser.platform.tracing_controller.StartTracing(config) |
| 27 | 28 |
| 28 def ComputeAverageOfDurations(self, timeline_model, name): | 29 def ComputeAverageOfDurations(self, timeline_model, name): |
| 29 events = timeline_model.GetAllEventsOfName(name) | 30 events = timeline_model.GetAllEventsOfName(name) |
| 30 event_durations = [d.duration for d in events] | 31 event_durations = [d.duration for d in events] |
| 31 assert event_durations, 'Failed to find durations' | 32 assert event_durations, 'Failed to find durations' |
| 32 | 33 |
| 33 duration_sum = sum(event_durations) | 34 duration_sum = sum(event_durations) |
| 34 duration_count = len(event_durations) | 35 duration_count = len(event_durations) |
| 35 duration_avg = duration_sum / duration_count | 36 duration_avg = duration_sum / duration_count |
| 36 return duration_avg | 37 return duration_avg |
| 37 | 38 |
| 38 def ValidateAndMeasurePage(self, page, tab, results): | 39 def ValidateAndMeasurePage(self, page, tab, results): |
| 40 del page # unused |
| 39 timeline_data = tab.browser.platform.tracing_controller.StopTracing() | 41 timeline_data = tab.browser.platform.tracing_controller.StopTracing() |
| 40 timeline_model = model.TimelineModel(timeline_data) | 42 timeline_model = model.TimelineModel(timeline_data) |
| 41 | 43 |
| 42 pt_avg = self.ComputeAverageOfDurations( | 44 pt_avg = self.ComputeAverageOfDurations( |
| 43 timeline_model, | 45 timeline_model, |
| 44 'LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees') | 46 'LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees') |
| 45 | 47 |
| 46 results.AddValue(scalar.ScalarValue( | 48 results.AddValue(scalar.ScalarValue( |
| 47 results.current_page, 'PT_avg_cost', 'ms', pt_avg, | 49 results.current_page, 'PT_avg_cost', 'ms', pt_avg, |
| 48 description='Average time spent processing property trees')) | 50 description='Average time spent processing property trees')) |
| 49 | 51 |
| 50 def DidRunPage(self, platform): | 52 def DidRunPage(self, platform): |
| 51 tracing_controller = platform.tracing_controller | 53 tracing_controller = platform.tracing_controller |
| 52 if tracing_controller.is_tracing_running: | 54 if tracing_controller.is_tracing_running: |
| 53 tracing_controller.StopTracing() | 55 tracing_controller.StopTracing() |
| OLD | NEW |