1 # Copyright 2014 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 tracing_category_filter
7 from telemetry
.web_perf
.metrics
import layout
9 from measurements
import timeline_controller
10 from metrics
import timeline
13 class ThreadTimes(page_test
.PageTest
):
14 def __init__(self
, report_silk_details
=False):
15 super(ThreadTimes
, self
).__init
__()
16 self
._timeline
_controller
= None
17 self
._report
_silk
_details
= report_silk_details
19 def WillNavigateToPage(self
, page
, tab
):
20 self
._timeline
_controller
= timeline_controller
.TimelineController(
21 enable_auto_issuing_record
=False)
22 if self
._report
_silk
_details
:
23 # We need the other traces in order to have any details to report.
24 self
._timeline
_controller
.trace_categories
= None
26 self
._timeline
_controller
.trace_categories
= \
27 tracing_category_filter
.CreateNoOverheadFilter().filter_string
28 self
._timeline
_controller
.SetUp(page
, tab
)
30 def DidNavigateToPage(self
, page
, tab
):
31 self
._timeline
_controller
.Start(tab
)
33 def ValidateAndMeasurePage(self
, page
, tab
, results
):
34 self
._timeline
_controller
.Stop(tab
, results
)
35 metric
= timeline
.ThreadTimesTimelineMetric()
37 self
._timeline
_controller
.model
.GetRendererThreadFromTabId(tab
.id)
38 if self
._report
_silk
_details
:
39 metric
.details_to_report
= timeline
.ReportSilkDetails
40 metric
.AddResults(self
._timeline
_controller
.model
, renderer_thread
,
41 self
._timeline
_controller
.smooth_records
, results
)
42 layout_metric
= layout
.LayoutMetric()
43 layout_metric
.AddResults(self
._timeline
_controller
.model
, renderer_thread
,
44 self
._timeline
_controller
.smooth_records
, results
)
46 def DidRunPage(self
, platform
):
47 if self
._timeline
_controller
:
48 self
._timeline
_controller
.CleanUp(platform
)