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

Unified Diff: tools/telemetry/telemetry/core/timeline/slice.py

Issue 19772005: [telemetry] Timeline model cleanups (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move things around and update docs Created 7 years, 5 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
Index: tools/telemetry/telemetry/core/timeline/slice.py
diff --git a/tools/telemetry/telemetry/core/timeline/tracing/slice.py b/tools/telemetry/telemetry/core/timeline/slice.py
similarity index 51%
rename from tools/telemetry/telemetry/core/timeline/tracing/slice.py
rename to tools/telemetry/telemetry/core/timeline/slice.py
index 178b33a00d7e8e32bd8e283f8f40ca44eef16b99..d8054ef699d6633be6652ea70f59b9179e8cdb0b 100644
--- a/tools/telemetry/telemetry/core/timeline/tracing/slice.py
+++ b/tools/telemetry/telemetry/core/timeline/slice.py
@@ -5,30 +5,40 @@
import telemetry.core.timeline.event as timeline_event
class Slice(timeline_event.TimelineEvent):
- ''' A Slice represents an interval of time plus parameters associated
+ """A Slice represents an interval of time plus parameters associated
with that interval.
NOTE: The Sample class implements the same interface as
Slice. These must be kept in sync.
All time units are stored in milliseconds.
- '''
- def __init__(self, category, name, timestamp, args=None, parent=None):
+ """
+ def __init__(self, category, name, timestamp,
+ args=None, parent=None, duration=0):
super(Slice, self).__init__(
- name, timestamp, 0, args=args, parent=parent)
- self._sub_slices = []
- self.category = category
+ category, name, timestamp, duration, args=args, parent=parent)
+ self.sub_slices = []
self.did_not_finish = False
- @property
- def sub_slices(self):
- return self._sub_slices
-
def AddSubSlice(self, sub_slice):
- self._sub_slices.append(sub_slice)
+ assert sub_slice.parent == self
+ self.sub_slices.append(sub_slice)
+
+ def IterEventsInThisContainerRecrusively(self):
+ for sub_slice in self.sub_slices:
+ yield sub_slice
+ for sub_sub in sub_slice.IterEventsInThisContainerRecrusively():
+ yield sub_sub
+
+ @property
+ def self_time(self):
+ """Time spent in this function less any time spent in child events."""
+ child_total = sum(
+ [e.duration for e in self.sub_slices])
+ return self.duration - child_total
def _GetSubSlicesRecursive(self):
- for sub_slice in self._sub_slices:
+ for sub_slice in self.sub_slices:
for s in sub_slice.GetAllSubSlices():
yield s
yield sub_slice

Powered by Google App Engine
This is Rietveld 408576698