OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 from measurements import timeline_controller | 4 from measurements import timeline_controller |
5 from metrics import timeline | 5 from metrics import timeline |
6 from telemetry.core.backends.chrome import tracing_backend | 6 from telemetry.core.platform import tracing_category_filter |
7 from telemetry.page import page_measurement | 7 from telemetry.page import page_measurement |
8 | 8 |
9 class ThreadTimes(page_measurement.PageMeasurement): | 9 class ThreadTimes(page_measurement.PageMeasurement): |
10 def __init__(self): | 10 def __init__(self): |
11 super(ThreadTimes, self).__init__('RunSmoothness') | 11 super(ThreadTimes, self).__init__('RunSmoothness') |
12 self._timeline_controller = None | 12 self._timeline_controller = None |
13 | 13 |
14 @classmethod | 14 @classmethod |
15 def AddCommandLineArgs(cls, parser): | 15 def AddCommandLineArgs(cls, parser): |
16 parser.add_option('--report-silk-results', action='store_true', | 16 parser.add_option('--report-silk-results', action='store_true', |
17 help='Report results relevant to silk.') | 17 help='Report results relevant to silk.') |
18 parser.add_option('--report-silk-details', action='store_true', | 18 parser.add_option('--report-silk-details', action='store_true', |
19 help='Report details relevant to silk.') | 19 help='Report details relevant to silk.') |
20 | 20 |
21 def WillNavigateToPage(self, page, tab): | 21 def WillNavigateToPage(self, page, tab): |
22 self._timeline_controller = timeline_controller.TimelineController() | 22 self._timeline_controller = timeline_controller.TimelineController() |
23 if self.options.report_silk_details: | 23 if self.options.report_silk_details: |
24 # We need the other traces in order to have any details to report. | 24 # We need the other traces in order to have any details to report. |
25 self.timeline_controller.trace_categories = \ | 25 self.timeline_controller.trace_categories = None |
26 tracing_backend.DEFAULT_TRACE_CATEGORIES | |
27 else: | 26 else: |
28 self._timeline_controller.trace_categories = \ | 27 self._timeline_controller.trace_categories = \ |
29 tracing_backend.MINIMAL_TRACE_CATEGORIES | 28 tracing_category_filter.CreateNoOverheadFilter().filter_string |
30 self._timeline_controller.SetUp(page, tab) | 29 self._timeline_controller.SetUp(page, tab) |
31 | 30 |
32 def WillRunActions(self, page, tab): | 31 def WillRunActions(self, page, tab): |
33 self._timeline_controller.Start(tab) | 32 self._timeline_controller.Start(tab) |
34 | 33 |
35 def DidRunActions(self, page, tab): | 34 def DidRunActions(self, page, tab): |
36 self._timeline_controller.Stop(tab) | 35 self._timeline_controller.Stop(tab) |
37 | 36 |
38 def MeasurePage(self, page, tab, results): | 37 def MeasurePage(self, page, tab, results): |
39 metric = timeline.ThreadTimesTimelineMetric() | 38 metric = timeline.ThreadTimesTimelineMetric() |
40 renderer_thread = \ | 39 renderer_thread = \ |
41 self._timeline_controller.model.GetRendererThreadFromTabId(tab.id) | 40 self._timeline_controller.model.GetRendererThreadFromTabId(tab.id) |
42 if self.options.report_silk_results: | 41 if self.options.report_silk_results: |
43 metric.results_to_report = timeline.ReportSilkResults | 42 metric.results_to_report = timeline.ReportSilkResults |
44 if self.options.report_silk_details: | 43 if self.options.report_silk_details: |
45 metric.details_to_report = timeline.ReportSilkDetails | 44 metric.details_to_report = timeline.ReportSilkDetails |
46 metric.AddResults(self._timeline_controller.model, renderer_thread, | 45 metric.AddResults(self._timeline_controller.model, renderer_thread, |
47 self._timeline_controller.smooth_records, results) | 46 self._timeline_controller.smooth_records, results) |
48 | 47 |
49 def CleanUpAfterPage(self, _, tab): | 48 def CleanUpAfterPage(self, _, tab): |
50 self._timeline_controller.CleanUp(tab) | 49 self._timeline_controller.CleanUp(tab) |
OLD | NEW |