Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import re | 5 import re |
| 6 | 6 |
| 7 | 7 |
| 8 def IsTimelineInteractionRecord(event_name): | 8 def IsTimelineInteractionRecord(event_name): |
| 9 return event_name.startswith('Interaction.') | 9 return event_name.startswith('Interaction.') |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 setTimeout(function() { | 39 setTimeout(function() { |
| 40 console.timeEnd(str); | 40 console.timeEnd(str); |
| 41 }, 1000); | 41 }, 1000); |
| 42 | 42 |
| 43 When run with perf.measurements.timeline_based_measurement running, this will | 43 When run with perf.measurements.timeline_based_measurement running, this will |
| 44 then cause a TimelineInteractionRecord to be created for this range and both | 44 then cause a TimelineInteractionRecord to be created for this range and both |
| 45 smoothness and network metrics to be reported for the marked up 1000ms | 45 smoothness and network metrics to be reported for the marked up 1000ms |
| 46 time-range. | 46 time-range. |
| 47 | 47 |
| 48 """ | 48 """ |
| 49 def __init__(self, event): | 49 def __init__(self, start, end): |
| 50 self.start = event.start | 50 self.start = start |
|
nduca
2014/03/07 20:05:56
i'd like logical_name to be mandatory
| |
| 51 self.end = event.end | 51 self.end = end |
| 52 self.logical_name = '' | |
| 53 self.is_smooth = False | |
| 54 self.is_loading_resources = False | |
| 52 | 55 |
| 56 @staticmethod | |
| 57 def FromEvent(event): | |
| 58 record = TimelineInteractionRecord(event.start, event.end) | |
| 53 m = re.match('Interaction\.(.+)\/(.+)', event.name) | 59 m = re.match('Interaction\.(.+)\/(.+)', event.name) |
| 54 if m: | 60 if m: |
| 55 self.logical_name = m.group(1) | 61 record.logical_name = m.group(1) |
| 56 if m.group(1) != '': | 62 if m.group(1) != '': |
| 57 flags = m.group(2).split(',') | 63 flags = m.group(2).split(',') |
| 58 else: | 64 else: |
| 59 flags = [] | 65 flags = [] |
| 60 else: | 66 else: |
| 61 m = re.match('Interaction\.(.+)', event.name) | 67 m = re.match('Interaction\.(.+)', event.name) |
| 62 assert m | 68 assert m |
| 63 self.logical_name = m.group(1) | 69 record.logical_name = m.group(1) |
| 64 flags = [] | 70 flags = [] |
| 65 | 71 |
| 66 for f in flags: | 72 for f in flags: |
| 67 if not f in ('is_smooth', 'is_loading_resources'): | 73 if not f in ('is_smooth', 'is_loading_resources'): |
| 68 raise Exception( | 74 raise Exception( |
| 69 'Unrecognized flag in timeline Interaction record: %s' % f) | 75 'Unrecognized flag in timeline Interaction record: %s' % f) |
| 70 self.is_smooth = 'is_smooth' in flags | 76 record.is_smooth = 'is_smooth' in flags |
| 71 self.is_loading_resources = 'is_loading_resources' in flags | 77 record.is_loading_resources = 'is_loading_resources' in flags |
| 78 return record | |
| 79 | |
| 80 @staticmethod | |
| 81 def FromBounds(bounds): | |
|
nduca
2014/03/07 20:05:56
logical name is required
| |
| 82 record = TimelineInteractionRecord(bounds.min, bounds.max) | |
| 83 return record | |
| 72 | 84 |
| 73 def GetResultNameFor(self, result_name): | 85 def GetResultNameFor(self, result_name): |
| 74 return "%s/%s" % (self.logical_name, result_name) | 86 if self.logical_name: |
| 87 return "%s-%s" % (self.logical_name, result_name) | |
| 88 else: | |
| 89 return result_name | |
| OLD | NEW |