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.
4 from measurements
import timeline_controller
5 from metrics
import timeline
6 from telemetry
.core
.platform
import tracing_category_filter
7 from telemetry
.page
import page_test
9 class ThreadTimes(page_test
.PageTest
):
10 def __init__(self
, report_silk_details
=False,
11 action_name_to_run
='RunSmoothness'):
12 super(ThreadTimes
, self
).__init
__(action_name_to_run
=action_name_to_run
)
13 self
._timeline
_controller
= None
14 self
._report
_silk
_details
= report_silk_details
16 def WillNavigateToPage(self
, page
, tab
):
17 self
._timeline
_controller
= timeline_controller
.TimelineController()
18 if self
._report
_silk
_details
:
19 # We need the other traces in order to have any details to report.
20 self
._timeline
_controller
.trace_categories
= None
22 self
._timeline
_controller
.trace_categories
= \
23 tracing_category_filter
.CreateNoOverheadFilter().filter_string
24 self
._timeline
_controller
.SetUp(page
, tab
)
26 def WillRunActions(self
, page
, tab
):
27 self
._timeline
_controller
.Start(tab
)
29 def DidRunActions(self
, page
, tab
):
30 self
._timeline
_controller
.Stop(tab
)
32 def ValidateAndMeasurePage(self
, page
, tab
, results
):
33 metric
= timeline
.ThreadTimesTimelineMetric()
35 self
._timeline
_controller
.model
.GetRendererThreadFromTabId(tab
.id)
36 if self
._report
_silk
_details
:
37 metric
.details_to_report
= timeline
.ReportSilkDetails
38 metric
.AddResults(self
._timeline
_controller
.model
, renderer_thread
,
39 self
._timeline
_controller
.smooth_records
, results
)
41 def CleanUpAfterPage(self
, _
, tab
):
42 self
._timeline
_controller
.CleanUp(tab
)