OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 from telemetry.core.platform import tracing_category_filter |
| 6 from telemetry.core.platform import tracing_options |
| 7 from telemetry.page import page_test |
| 8 from telemetry.timeline import model |
| 9 from telemetry.value import scalar |
| 10 |
| 11 |
| 12 class DrawProperties(page_test.PageTest): |
| 13 def __init__(self): |
| 14 super(DrawProperties, self).__init__( |
| 15 action_name_to_run='RunPageInteractions') |
| 16 |
| 17 def CustomizeBrowserOptions(self, options): |
| 18 options.AppendExtraBrowserArgs('--enable-property-tree-verification') |
| 19 |
| 20 def WillNavigateToPage(self, page, tab): |
| 21 options = tracing_options.TracingOptions() |
| 22 options.enable_chrome_trace = True |
| 23 category_filter = tracing_category_filter.TracingCategoryFilter( |
| 24 'disabled-by-default-cc.debug.cdp-perf') |
| 25 tab.browser.platform.tracing_controller.Start(options, category_filter) |
| 26 |
| 27 def ValidateAndMeasurePage(self, page, tab, results): |
| 28 timeline_data = tab.browser.platform.tracing_controller.Stop() |
| 29 timeline_model = model.TimelineModel(timeline_data) |
| 30 |
| 31 def _IsDone(): |
| 32 return tab.EvaluateJavaScript('isDone') |
| 33 |
| 34 cdp_events = timeline_model.GetAllEventsOfName( |
| 35 "LayerTreeHostCommon::CalculateDrawProperties"); |
| 36 |
| 37 durations = [d.duration for d in cdp_events] |
| 38 assert durations, 'Failed to find cdp durations' |
| 39 |
| 40 cdp_sum = sum(durations) |
| 41 |
| 42 pt_events = timeline_model.GetAllEventsOfName( |
| 43 "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees"); |
| 44 |
| 45 durations = [d.duration for d in pt_events] |
| 46 assert durations, 'Failed to find pt durations' |
| 47 |
| 48 pt_sum = sum(durations) |
| 49 |
| 50 reduction = 100.0 * (1.0 - (pt_sum / cdp_sum)) |
| 51 |
| 52 results.AddValue(scalar.ScalarValue( |
| 53 results.current_page, 'CDP_reduction', 'percent', reduction, |
| 54 description='Reduction in CDP cost with property trees')) |
| 55 |
| 56 def CleanUpAfterPage(self, page, tab): |
| 57 tracing_controller = tab.browser.platform.tracing_controller |
| 58 if tracing_controller.is_tracing_running: |
| 59 tracing_controller.Stop() |
OLD | NEW |