Index: tools/perf/metrics/timeline_interaction_record.py |
diff --git a/tools/perf/metrics/timeline_interaction_record.py b/tools/perf/metrics/timeline_interaction_record.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3ec90025ae25b300abe0d9c4b05c3ef362b5d41d |
--- /dev/null |
+++ b/tools/perf/metrics/timeline_interaction_record.py |
@@ -0,0 +1,38 @@ |
+# Copyright 2014 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import re |
+ |
+ |
+def IsTimelineInteractionRecord(event_name): |
+ return event_name.startswith('Interaction.') |
+ |
+ |
+class TimelineInteractionRecord(object): |
+ def __init__(self, event): |
+ self.start = event.start |
+ self.end = event.end |
+ |
+ m = re.match('Interaction\.(.+)\/(.+)', event.name) |
+ if m: |
+ self.logical_name = m.group(1) |
+ if m.group(1) != '': |
+ flags = m.group(2).split(',') |
+ else: |
+ flags = [] |
+ else: |
+ m = re.match('Interaction\.(.+)', event.name) |
+ assert m |
+ self.logical_name = m.group(1) |
+ flags = [] |
+ |
+ for f in flags: |
+ if not f in ('is_smooth', 'is_loading_resources'): |
+ raise Exception( |
+ 'Unrecognized flag in timeline Interaction record: %s' % f) |
+ self.is_smooth = 'is_smooth' in flags |
+ self.is_loading_resources = 'is_loading_resources' in flags |
+ |
+ def GetResultNameFor(self, result_name): |
+ return "%s/%s" % (self.logical_name, result_name) |