Index: tools/telemetry/telemetry/web_perf/timeline_interaction_record.py |
diff --git a/tools/telemetry/telemetry/web_perf/timeline_interaction_record.py b/tools/telemetry/telemetry/web_perf/timeline_interaction_record.py |
index 1879b0d365b27b977e72b864ad5b0658dc0c2c1a..ab8ef5ae156c905422bdfe93a5d41574f8819670 100644 |
--- a/tools/telemetry/telemetry/web_perf/timeline_interaction_record.py |
+++ b/tools/telemetry/telemetry/web_perf/timeline_interaction_record.py |
@@ -5,6 +5,7 @@ |
import re |
from telemetry import decorators |
+from telemetry.timeline import async_slice as async_slice_module |
import telemetry.timeline.bounds as timeline_bounds |
@@ -30,13 +31,36 @@ class ThreadTimeRangeOverlappedException(Exception): |
with other events. |
""" |
+ |
class NoThreadTimeDataException(ThreadTimeRangeOverlappedException): |
"""Exception that can be thrown if there is not sufficient thread time data |
to compute the overlapped thread time range.""" |
+ |
def IsTimelineInteractionRecord(event_name): |
return event_name.startswith('Interaction.') |
+ |
+def _IsAsyncSlice(t): |
+ return t == async_slice_module.AsyncSlice |
+ |
+ |
+def GetThreadToInteractionRecordsMapsFromModel(timeline_model): |
+ threads_to_records_map = {} |
+ for thread in timeline_model.GetAllThreads(): |
+ for event in thread.async_slices: |
+ if not IsTimelineInteractionRecord(event.name): |
+ continue |
+ assert event.start_thread |
+ assert event.start_thread is event.end_thread |
+ record_thread = event.start_thread |
+ if record_thread not in threads_to_records_map: |
+ threads_to_records_map[record_thread] = [] |
+ threads_to_records_map[record_thread].append( |
+ TimelineInteractionRecord.FromAsyncEvent(event)) |
+ return threads_to_records_map |
+ |
+ |
def _AssertFlagsAreValid(flags): |
assert isinstance(flags, list) |
for f in flags: |
@@ -44,6 +68,7 @@ def _AssertFlagsAreValid(flags): |
raise AssertionError( |
'Unrecognized flag for a timeline interaction record: %s' % f) |
+ |
def GetJavaScriptMarker(label, flags): |
"""Computes the marker string of an interaction record. |
@@ -117,6 +142,10 @@ class TimelineInteractionRecord(object): |
_AssertFlagsAreValid(self._flags) |
@property |
+ def async_event(self): |
+ return self._async_event |
+ |
+ @property |
def label(self): |
return self._label |