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

Unified Diff: tools/telemetry/telemetry/web_perf/timeline_interaction_record.py

Issue 439383002: Add GetThreadToInteractionRecordsMapsFromModel method to timeline_interaction_record. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/telemetry/telemetry/web_perf/timeline_based_measurement.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « tools/telemetry/telemetry/web_perf/timeline_based_measurement.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698