Don't add extra app list launcher page webviews.
[chromium-blink-merge.git] / tools / perf / measurements / draw_properties.py
bloba38fb6e4fdcf2480605285d98d72febd6ebe266b
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.
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
12 class DrawProperties(page_test.PageTest):
13 def __init__(self):
14 super(DrawProperties, self).__init__()
16 def CustomizeBrowserOptions(self, options):
17 options.AppendExtraBrowserArgs([
18 '--enable-property-tree-verification',
19 '--enable-prefer-compositing-to-lcd-text',
22 def WillNavigateToPage(self, page, tab):
23 options = tracing_options.TracingOptions()
24 options.enable_chrome_trace = True
25 category_filter = tracing_category_filter.TracingCategoryFilter(
26 'disabled-by-default-cc.debug.cdp-perf')
27 tab.browser.platform.tracing_controller.Start(options, category_filter)
29 def ComputeAverageAndSumOfDurations(self, timeline_model, name):
30 events = timeline_model.GetAllEventsOfName(name)
31 event_durations = [d.duration for d in events]
32 assert event_durations, 'Failed to find durations'
34 duration_sum = sum(event_durations)
35 duration_count = len(event_durations)
36 duration_avg = duration_sum / duration_count
37 return (duration_avg, duration_sum)
39 def ValidateAndMeasurePage(self, page, tab, results):
40 timeline_data = tab.browser.platform.tracing_controller.Stop()
41 timeline_model = model.TimelineModel(timeline_data)
43 (cdp_avg, cdp_sum) = self.ComputeAverageAndSumOfDurations(
44 timeline_model,
45 "LayerTreeHostCommon::CalculateDrawProperties");
47 (pt_avg, pt_sum) = self.ComputeAverageAndSumOfDurations(
48 timeline_model,
49 "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees");
51 reduction = 100.0 * (1.0 - (pt_sum / cdp_sum))
53 results.AddValue(scalar.ScalarValue(
54 results.current_page, 'CDP_reduction', ' %', reduction,
55 description='Reduction in CDP cost with property trees'))
57 results.AddValue(scalar.ScalarValue(
58 results.current_page, 'CDP_avg_cost', 'ms', cdp_avg,
59 description='Average time spent in CDP'))
61 results.AddValue(scalar.ScalarValue(
62 results.current_page, 'PT_avg_cost', 'ms', pt_avg,
63 description='Average time spent processing property trees'))
65 def CleanUpAfterPage(self, page, tab):
66 tracing_controller = tab.browser.platform.tracing_controller
67 if tracing_controller.is_tracing_running:
68 tracing_controller.Stop()