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

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

Issue 100073003: telemetry: Add thread time to telmetry timeline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean-ups Created 7 years 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 8b9db4cef72e082401be71fb0bf9ab3f32b591b9..916d540eabe8d2bdab06a28ef2d762c0ae71e980 100644
--- a/tools/telemetry/telemetry/core/timeline/event.py
+++ b/tools/telemetry/telemetry/core/timeline/event.py
@@ -3,26 +3,50 @@
# found in the LICENSE file.
class TimelineEvent(object):
- """Represents a timeline event."""
- def __init__(self, category, name, start, duration, args=None):
+ """Represents a timeline event.
+
+ thread_start, thread_duration and thread_end are the start time, duration
+ and end time of this event as measured by the thread-specific CPU clock
+ (ticking when the thread is actually scheduled). Thread time is optional
+ on trace events and the corresponding attributes in TimelineEvent will be
+ set to None (not 0) if not present. Users of this class need to properly
+ handle this case.
+ """
+ def __init__(self, category, name, start, duration, thread_start=None,
+ thread_duration=None, args=None):
self.category = category
self.name = name
self.start = start
self.duration = duration
+ self.thread_start = thread_start
+ self.thread_duration = thread_duration
self.args = args
@property
def end(self):
return self.start + self.duration
+ @property
+ def thread_end(self):
+ """Thread-specific CPU time when this event ended.
+
+ May be None if the trace event didn't have thread time data.
+ """
+ if self.thread_start == None or self.thread_duration == None:
+ return None
+ return self.thread_start + self.thread_duration
+
def __repr__(self):
if self.args:
args_str = ', ' + repr(self.args)
else:
args_str = ''
- return "TimelineEvent(name='%s', start=%f, duration=%s%s)" % (
- self.name,
- self.start,
- self.duration,
- args_str)
+ return ("TimelineEvent(name='%s', start=%f, duration=%s, " +
+ "thread_start=%s, thread_duration=%s%s)") % (
+ self.name,
+ self.start,
+ self.duration,
+ self.thread_start,
+ self.thread_duration,
+ args_str)
« no previous file with comments | « tools/telemetry/telemetry/core/timeline/counter.py ('k') | tools/telemetry/telemetry/core/timeline/inspector_importer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698