| 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 | 4 from measurements import timeline_controller |
| 5 from metrics import timeline | 5 from metrics import timeline |
| 6 from telemetry.page import page_measurement | 6 from telemetry.page import page_measurement |
| 7 | 7 |
| 8 class ThreadTimes(page_measurement.PageMeasurement): | 8 class ThreadTimes(page_measurement.PageMeasurement): |
| 9 def __init__(self): | 9 def __init__(self): |
| 10 super(ThreadTimes, self).__init__('RunSmoothness') | 10 super(ThreadTimes, self).__init__('RunSmoothness') |
| 11 self._metric = None | 11 self._timeline_controller = None |
| 12 | 12 |
| 13 @classmethod | 13 @classmethod |
| 14 def AddCommandLineArgs(cls, parser): | 14 def AddCommandLineArgs(cls, parser): |
| 15 parser.add_option('--report-silk-results', action='store_true', | 15 parser.add_option('--report-silk-results', action='store_true', |
| 16 help='Report results relevant to silk.') | 16 help='Report results relevant to silk.') |
| 17 parser.add_option('--report-silk-details', action='store_true', | 17 parser.add_option('--report-silk-details', action='store_true', |
| 18 help='Report details relevant to silk.') | 18 help='Report details relevant to silk.') |
| 19 | 19 |
| 20 @property | 20 @property |
| 21 def results_are_the_same_on_every_page(self): | 21 def results_are_the_same_on_every_page(self): |
| 22 return False | 22 return False |
| 23 | 23 |
| 24 def WillRunActions(self, page, tab): | 24 def WillRunActions(self, page, tab): |
| 25 self._metric = timeline.ThreadTimesTimelineMetric() | 25 self._timeline_controller = timeline_controller.TimelineController() |
| 26 if self.options.report_silk_results: | |
| 27 self._metric.results_to_report = timeline.ReportSilkResults | |
| 28 if self.options.report_silk_details: | 26 if self.options.report_silk_details: |
| 29 self._metric.details_to_report = timeline.ReportSilkDetails | 27 # We need the other traces in order to have any details to report. |
| 30 self._metric.Start(page, tab) | 28 self.timeline_controller.trace_categories = \ |
| 29 timeline_controller.DEFAULT_TRACE_CATEGORIES |
| 30 else: |
| 31 self._timeline_controller.trace_categories = \ |
| 32 timeline_controller.MINIMAL_TRACE_CATEGORIES |
| 33 self._timeline_controller.Start(page, tab) |
| 31 | 34 |
| 32 def DidRunAction(self, page, tab, action): | 35 def DidRunAction(self, page, tab, action): |
| 33 self._metric.AddActionToIncludeInMetric(action) | 36 self._timeline_controller.AddActionToIncludeInMetric(action) |
| 34 | 37 |
| 35 def DidRunActions(self, page, tab): | 38 def DidRunActions(self, page, tab): |
| 36 self._metric.Stop(page, tab) | 39 self._timeline_controller.Stop(tab) |
| 37 | 40 |
| 38 def MeasurePage(self, page, tab, results): | 41 def MeasurePage(self, page, tab, results): |
| 39 self._metric.AddResults(tab, results) | 42 metric = timeline.ThreadTimesTimelineMetric( |
| 43 self._timeline_controller.model, |
| 44 self._timeline_controller.renderer_process, |
| 45 self._timeline_controller.action_ranges) |
| 46 if self.options.report_silk_results: |
| 47 metric.results_to_report = timeline.ReportSilkResults |
| 48 if self.options.report_silk_details: |
| 49 metric.details_to_report = timeline.ReportSilkDetails |
| 50 metric.AddResults(tab, results) |
| OLD | NEW |