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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/measurements/timeline_controller.py
diff --git a/tools/perf/measurements/timeline_controller.py b/tools/perf/measurements/timeline_controller.py
new file mode 100644
index 0000000000000000000000000000000000000000..d9ca0bceb026b17a9e8c9ae52cb47f264e5d7c6f
--- /dev/null
+++ b/tools/perf/measurements/timeline_controller.py
@@ -0,0 +1,70 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import itertools
+
+from telemetry.core.timeline.model import TimelineModel
+
+# All tracing categories not disabled-by-default
+DEFAULT_TRACE_CATEGORIES = None
+
+# Categories for absolute minimum overhead tracing. This contains no
+# sub-traces of thread tasks, so it's only useful for capturing the
+# cpu-time spent on threads (as well as needed benchmark traces)
+MINIMAL_TRACE_CATEGORIES = ("toplevel,"
+ "benchmark,"
+ "webkit.console,"
+ "trace_event_overhead")
+
+
+class TimelineController(object):
+ def __init__(self):
+ super(TimelineController, self).__init__()
+ self.trace_categories = DEFAULT_TRACE_CATEGORIES
+ self._model = None
+ self._renderer_process = None
+ self._actions = []
+ self._action_ranges = []
+
+ def Start(self, page, tab):
+ """Starts gathering timeline data.
+
+ """
+ # Resets these member variables incase this object is reused.
+ self._model = None
+ self._renderer_process = None
+ self._actions = []
+ self._action_ranges = []
+ if not tab.browser.supports_tracing:
+ raise Exception('Not supported')
+ if self.trace_categories:
+ categories = [self.trace_categories] + \
+ page.GetSyntheticDelayCategories()
+ else:
+ categories = page.GetSyntheticDelayCategories()
+ tab.browser.StartTracing(','.join(categories))
+
+ def Stop(self, tab):
+ timeline_data = tab.browser.StopTracing()
+ self._model = TimelineModel(timeline_data)
+ self._renderer_process = self._model.GetRendererProcessFromTab(tab)
+ self._action_ranges = [ action.GetActiveRangeOnTimeline(self._model)
+ for action in self._actions ]
+ # Make sure no action ranges overlap
+ for combo in itertools.combinations(self._action_ranges, 2):
+ assert not combo[0].Intersects(combo[1])
+
+ def AddActionToIncludeInMetric(self, action):
+ self._actions.append(action)
+
+ @property
+ def model(self):
+ return self._model
+
+ @property
+ def renderer_process(self):
+ return self._renderer_process
+
+ @property
+ def action_ranges(self):
+ return self._action_ranges
« 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