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

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

Issue 19790005: Reland [telemetry] Timeline model cleanups (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/event.py
diff --git a/tools/telemetry/telemetry/core/timeline/event.py b/tools/telemetry/telemetry/core/timeline/event.py
index 6b8d8db9ee8dd7a58b91871991053dd6ca5889b4..8b9db4cef72e082401be71fb0bf9ab3f32b591b9 100644
--- a/tools/telemetry/telemetry/core/timeline/event.py
+++ b/tools/telemetry/telemetry/core/timeline/event.py
@@ -4,25 +4,17 @@
class TimelineEvent(object):
"""Represents a timeline event."""
- def __init__(self, name, start, duration, args=None, parent=None):
+ def __init__(self, category, name, start, duration, args=None):
+ self.category = category
self.name = name
self.start = start
self.duration = duration
- self.children = []
- self.parent = parent
self.args = args
@property
def end(self):
return self.start + self.duration
- @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.children])
- return self.duration - child_total
-
def __repr__(self):
if self.args:
args_str = ', ' + repr(self.args)
@@ -34,39 +26,3 @@ class TimelineEvent(object):
self.start,
self.duration,
args_str)
-
- @staticmethod
- def _GetAllChildrenRecursive(events, item):
- events.append(item)
- for child in item.children:
- TimelineEvent._GetAllChildrenRecursive(events, child)
-
- def GetAllChildrenRecursive(self, include_self=False):
- events = []
- TimelineEvent._GetAllChildrenRecursive(events, self)
- if not include_self:
- del events[0]
- return events
-
- def ShiftTimestampsForward(self, delta_time):
- """ Shifts start time of event by delta_time and also
- recursively shifts child events.
- """
- for event in self.children:
- event.ShiftTimestampsForward(delta_time)
- self.start += delta_time
-
- def UpdateBounds(self):
- """ Updates the start time to be the minimum start time of all
- child events and the end time to be the maximum end time of all
- child events.
- """
- if not len(self.children):
- return
-
- for event in self.children:
- event.UpdateBounds()
-
- self.start = min(self.children, key=lambda e: e.start).start
- end_timestamp = max(self.children, key=lambda e: e.end).end
- self.duration = end_timestamp - self.start
« no previous file with comments | « tools/telemetry/telemetry/core/timeline/counter.py ('k') | tools/telemetry/telemetry/core/timeline/event_container.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698