| 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 import collections | 4 import collections |
| 5 import itertools | 5 import itertools |
| 6 | 6 |
| 7 from metrics import Metric | 7 from metrics import Metric |
| 8 from telemetry.core.timeline.model import TimelineModel | 8 from telemetry.core.timeline.model import TimelineModel |
| 9 from telemetry.core.timeline import bounds | 9 from telemetry.core.timeline import bounds |
| 10 from telemetry.page import page_measurement | 10 from telemetry.page import page_measurement |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 def Start(self, page, tab): | 45 def Start(self, page, tab): |
| 46 """Starts gathering timeline data. | 46 """Starts gathering timeline data. |
| 47 | 47 |
| 48 mode: TRACING_MODE or TIMELINE_MODE | 48 mode: TRACING_MODE or TIMELINE_MODE |
| 49 """ | 49 """ |
| 50 self._model = None | 50 self._model = None |
| 51 if self._mode == TRACING_MODE: | 51 if self._mode == TRACING_MODE: |
| 52 if not tab.browser.supports_tracing: | 52 if not tab.browser.supports_tracing: |
| 53 raise Exception('Not supported') | 53 raise Exception('Not supported') |
| 54 tab.browser.StartTracing(self.trace_categories) | 54 if self.trace_categories: |
| 55 categories = [self.trace_categories] + \ |
| 56 page.GetSyntheticDelayCategories() |
| 57 else: |
| 58 categories = page.GetSyntheticDelayCategories() |
| 59 tab.browser.StartTracing(','.join(categories)) |
| 55 else: | 60 else: |
| 56 assert self._mode == TIMELINE_MODE | 61 assert self._mode == TIMELINE_MODE |
| 57 tab.StartTimelineRecording() | 62 tab.StartTimelineRecording() |
| 58 | 63 |
| 59 def Stop(self, page, tab): | 64 def Stop(self, page, tab): |
| 60 if self._mode == TRACING_MODE: | 65 if self._mode == TRACING_MODE: |
| 61 timeline_data = tab.browser.StopTracing() | 66 timeline_data = tab.browser.StopTracing() |
| 62 self._model = TimelineModel(timeline_data) | 67 self._model = TimelineModel(timeline_data) |
| 63 self._renderer_process = self._model.GetRendererProcessFromTab(tab) | 68 self._renderer_process = self._model.GetRendererProcessFromTab(tab) |
| 64 self._action_ranges = [ action.GetActiveRangeOnTimeline(self._model) | 69 self._action_ranges = [ action.GetActiveRangeOnTimeline(self._model) |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 num_frames = self.CountSlices(frame_slices, FrameTraceName) | 343 num_frames = self.CountSlices(frame_slices, FrameTraceName) |
| 339 | 344 |
| 340 # Report the desired results and details. | 345 # Report the desired results and details. |
| 341 for thread_results in thread_category_results.values(): | 346 for thread_results in thread_category_results.values(): |
| 342 if thread_results.name in self.results_to_report: | 347 if thread_results.name in self.results_to_report: |
| 343 thread_results.AddResults(num_frames, results) | 348 thread_results.AddResults(num_frames, results) |
| 344 # TOOD(nduca): When generic results objects are done, this special case | 349 # TOOD(nduca): When generic results objects are done, this special case |
| 345 # can be replaced with a generic UI feature. | 350 # can be replaced with a generic UI feature. |
| 346 if thread_results.name in self.details_to_report: | 351 if thread_results.name in self.details_to_report: |
| 347 thread_results.AddDetailedResults(num_frames, results) | 352 thread_results.AddDetailedResults(num_frames, results) |
| OLD | NEW |