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 telemetry.page import legacy_page_test | 5 from telemetry.page import legacy_page_test |
6 from telemetry.timeline import chrome_trace_category_filter | 6 from telemetry.timeline import chrome_trace_category_filter |
7 from telemetry.web_perf.metrics import layout | 7 from telemetry.web_perf.metrics import layout |
8 | 8 |
9 from measurements import timeline_controller | 9 from measurements import timeline_controller |
10 from metrics import timeline | 10 from metrics import timeline |
11 | 11 |
12 | 12 |
13 class ThreadTimes(legacy_page_test.LegacyPageTest): | 13 class ThreadTimes(legacy_page_test.LegacyPageTest): |
14 | 14 |
15 def __init__(self, report_silk_details=False): | 15 def __init__(self, report_silk_details=False): |
16 super(ThreadTimes, self).__init__() | 16 super(ThreadTimes, self).__init__() |
17 self._timeline_controller = None | 17 self._timeline_controller = None |
18 self._report_silk_details = report_silk_details | 18 self._report_silk_details = report_silk_details |
19 | 19 |
20 def WillNavigateToPage(self, page, tab): | 20 def WillNavigateToPage(self, page, tab): |
21 self._timeline_controller = timeline_controller.TimelineController( | 21 self._timeline_controller = timeline_controller.TimelineController( |
22 enable_auto_issuing_record=False) | 22 enable_auto_issuing_record=False) |
23 if self._report_silk_details: | 23 if self._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 = None | 25 self._timeline_controller.trace_categories = None |
26 else: | 26 else: |
27 self._timeline_controller.trace_categories = \ | 27 self._timeline_controller.trace_categories = \ |
28 chrome_trace_category_filter.CreateNoOverheadFilter().filter_string | 28 chrome_trace_category_filter.CreateLowOverheadFilter().filter_string |
29 self._timeline_controller.SetUp(page, tab) | 29 self._timeline_controller.SetUp(page, tab) |
30 | 30 |
31 def DidNavigateToPage(self, page, tab): | 31 def DidNavigateToPage(self, page, tab): |
32 del page # unused | 32 del page # unused |
33 self._timeline_controller.Start(tab) | 33 self._timeline_controller.Start(tab) |
34 | 34 |
35 def ValidateAndMeasurePage(self, page, tab, results): | 35 def ValidateAndMeasurePage(self, page, tab, results): |
36 del page # unused | 36 del page # unused |
37 self._timeline_controller.Stop(tab, results) | 37 self._timeline_controller.Stop(tab, results) |
38 metric = timeline.ThreadTimesTimelineMetric() | 38 metric = timeline.ThreadTimesTimelineMetric() |
39 renderer_thread = \ | 39 renderer_thread = \ |
40 self._timeline_controller.model.GetRendererThreadFromTabId(tab.id) | 40 self._timeline_controller.model.GetRendererThreadFromTabId(tab.id) |
41 if self._report_silk_details: | 41 if self._report_silk_details: |
42 metric.details_to_report = timeline.ReportSilkDetails | 42 metric.details_to_report = timeline.ReportSilkDetails |
43 metric.AddResults(self._timeline_controller.model, renderer_thread, | 43 metric.AddResults(self._timeline_controller.model, renderer_thread, |
44 self._timeline_controller.smooth_records, results) | 44 self._timeline_controller.smooth_records, results) |
45 layout_metric = layout.LayoutMetric() | 45 layout_metric = layout.LayoutMetric() |
46 layout_metric.AddResults(self._timeline_controller.model, renderer_thread, | 46 layout_metric.AddResults(self._timeline_controller.model, renderer_thread, |
47 self._timeline_controller.smooth_records, results) | 47 self._timeline_controller.smooth_records, results) |
48 | 48 |
49 def DidRunPage(self, platform): | 49 def DidRunPage(self, platform): |
50 if self._timeline_controller: | 50 if self._timeline_controller: |
51 self._timeline_controller.CleanUp(platform) | 51 self._timeline_controller.CleanUp(platform) |
OLD | NEW |