| 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 |
| 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__('smoothness') | 10 super(ThreadTimes, self).__init__('smoothness') |
| 11 self._metric = None | 11 self._metric = None |
| 12 | 12 |
| 13 def AddCommandLineOptions(self, parser): | 13 def AddCommandLineOptions(self, parser): |
| 14 parser.add_option('--report-silk-results', action='store_true', | 14 parser.add_option('--report-silk-results', action='store_true', |
| 15 help='Report results relevant to silk.') | 15 help='Report results relevant to silk.') |
| 16 parser.add_option('--report-silk-details', action='store_true', | 16 parser.add_option('--report-silk-details', action='store_true', |
| 17 help='Report details relevant to silk.') | 17 help='Report details relevant to silk.') |
| 18 | 18 |
| 19 def CanRunForPage(self, page): | 19 def CanRunForPage(self, page): |
| 20 return hasattr(page, 'smoothness') | 20 return hasattr(page, 'smoothness') |
| 21 | 21 |
| 22 @property | 22 @property |
| 23 def results_are_the_same_on_every_page(self): | 23 def results_are_the_same_on_every_page(self): |
| 24 return False | 24 return False |
| 25 | 25 |
| 26 def WillRunActions(self, page, tab): | 26 def WillRunActions(self, page, tab): |
| 27 self._metric = timeline.ThreadTimesTimelineMetric() | 27 self._metric = timeline.ThreadTimesTimelineMetric() |
| 28 self._metric.Start(page, tab) | |
| 29 if self.options.report_silk_results: | 28 if self.options.report_silk_results: |
| 30 self._metric.results_to_report = timeline.ReportSilkResults | 29 self._metric.results_to_report = timeline.ReportSilkResults |
| 31 if self.options.report_silk_details: | 30 if self.options.report_silk_details: |
| 32 self._metric.details_to_report = timeline.ReportSilkDetails | 31 self._metric.details_to_report = timeline.ReportSilkDetails |
| 32 self._metric.Start(page, tab) |
| 33 | 33 |
| 34 def DidRunAction(self, page, tab, action): | 34 def DidRunAction(self, page, tab, action): |
| 35 self._metric.AddActionToIncludeInMetric(action) | 35 self._metric.AddActionToIncludeInMetric(action) |
| 36 | 36 |
| 37 def DidRunActions(self, page, tab): | 37 def DidRunActions(self, page, tab): |
| 38 self._metric.Stop(page, tab) | 38 self._metric.Stop(page, tab) |
| 39 | 39 |
| 40 def MeasurePage(self, page, tab, results): | 40 def MeasurePage(self, page, tab, results): |
| 41 self._metric.AddResults(tab, results) | 41 self._metric.AddResults(tab, results) |
| OLD | NEW |