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
.page
import page_test
6 from telemetry
.timeline
import model
7 from telemetry
.timeline
import tracing_category_filter
8 from telemetry
.timeline
import tracing_options
9 from telemetry
.value
import scalar
12 class DrawProperties(page_test
.PageTest
):
14 super(DrawProperties
, self
).__init
__()
16 def CustomizeBrowserOptions(self
, options
):
17 options
.AppendExtraBrowserArgs([
18 '--enable-prefer-compositing-to-lcd-text',
21 def WillNavigateToPage(self
, page
, tab
):
22 options
= tracing_options
.TracingOptions()
23 options
.enable_chrome_trace
= True
24 category_filter
= tracing_category_filter
.TracingCategoryFilter(
25 'disabled-by-default-cc.debug.cdp-perf')
26 tab
.browser
.platform
.tracing_controller
.Start(options
, category_filter
)
28 def ComputeAverageOfDurations(self
, timeline_model
, name
):
29 events
= timeline_model
.GetAllEventsOfName(name
)
30 event_durations
= [d
.duration
for d
in events
]
31 assert event_durations
, 'Failed to find durations'
33 duration_sum
= sum(event_durations
)
34 duration_count
= len(event_durations
)
35 duration_avg
= duration_sum
/ duration_count
38 def ValidateAndMeasurePage(self
, page
, tab
, results
):
39 timeline_data
= tab
.browser
.platform
.tracing_controller
.Stop()
40 timeline_model
= model
.TimelineModel(timeline_data
)
42 pt_avg
= self
.ComputeAverageOfDurations(
44 'LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees')
46 results
.AddValue(scalar
.ScalarValue(
47 results
.current_page
, 'PT_avg_cost', 'ms', pt_avg
,
48 description
='Average time spent processing property trees'))
50 def DidRunPage(self
, platform
):
51 tracing_controller
= platform
.tracing_controller
52 if tracing_controller
.is_tracing_running
:
53 tracing_controller
.Stop()