Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: tools/perf/measurements/timeline_controller.py

Issue 199733007: Remove start & stop logic from timeline_metric. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/perf/measurements/timeline_based_measurement.py ('k') | tools/perf/metrics/timeline.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4 import itertools
5
6 from telemetry.core.timeline.model import TimelineModel
7
8 # All tracing categories not disabled-by-default
9 DEFAULT_TRACE_CATEGORIES = None
10
11 # Categories for absolute minimum overhead tracing. This contains no
12 # sub-traces of thread tasks, so it's only useful for capturing the
13 # cpu-time spent on threads (as well as needed benchmark traces)
14 MINIMAL_TRACE_CATEGORIES = ("toplevel,"
15 "benchmark,"
16 "webkit.console,"
17 "trace_event_overhead")
18
19
20 class TimelineController(object):
21 def __init__(self):
22 super(TimelineController, self).__init__()
23 self.trace_categories = DEFAULT_TRACE_CATEGORIES
24 self._model = None
25 self._renderer_process = None
26 self._actions = []
27 self._action_ranges = []
28
29 def Start(self, page, tab):
30 """Starts gathering timeline data.
31
32 """
33 # Resets these member variables incase this object is reused.
34 self._model = None
35 self._renderer_process = None
36 self._actions = []
37 self._action_ranges = []
38 if not tab.browser.supports_tracing:
39 raise Exception('Not supported')
40 if self.trace_categories:
41 categories = [self.trace_categories] + \
42 page.GetSyntheticDelayCategories()
43 else:
44 categories = page.GetSyntheticDelayCategories()
45 tab.browser.StartTracing(','.join(categories))
46
47 def Stop(self, tab):
48 timeline_data = tab.browser.StopTracing()
49 self._model = TimelineModel(timeline_data)
50 self._renderer_process = self._model.GetRendererProcessFromTab(tab)
51 self._action_ranges = [ action.GetActiveRangeOnTimeline(self._model)
52 for action in self._actions ]
53 # Make sure no action ranges overlap
54 for combo in itertools.combinations(self._action_ranges, 2):
55 assert not combo[0].Intersects(combo[1])
56
57 def AddActionToIncludeInMetric(self, action):
58 self._actions.append(action)
59
60 @property
61 def model(self):
62 return self._model
63
64 @property
65 def renderer_process(self):
66 return self._renderer_process
67
68 @property
69 def action_ranges(self):
70 return self._action_ranges
OLDNEW
« no previous file with comments | « tools/perf/measurements/timeline_based_measurement.py ('k') | tools/perf/metrics/timeline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698