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

Unified Diff: tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric.py

Issue 1357423008: [Telemetry] AddIsEventInInteractions helper method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric.py
diff --git a/tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric.py b/tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric.py
index f406b12c1403169a175c9b550506c219cb5c6f00..71f3f15ad4e34d1fcb3e71c57af00e24306d339d 100644
--- a/tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric.py
+++ b/tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric.py
@@ -26,6 +26,23 @@ def _TimeRangesHasOverlap(iterable_time_ranges):
return False
+def IsEventInInteractions(event, interaction_records):
+ """ Return True if event is in any of the interaction records' time range.
+
+ Args:
+ event: an instance of telemetry.timeline.event.TimelineEvent.
+ interaction_records: a list of interaction records, whereas each record is
+ an instance of
+ telemetry.web_perf.timeline_interaction_record.TimelineInteractionRecord.
+
+ Returns:
+ True if |event|'s start & end time is in any of the |interaction_records|'s
+ time range.
+ """
+ return any(ir.start <= event.start and ir.end >= event.end for ir
+ in interaction_records)
+
+
class TimelineBasedMetric(object):
def __init__(self):
« no previous file with comments | « no previous file | tools/telemetry/telemetry/web_perf/metrics/timeline_based_metric_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698