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

Side by Side Diff: tools/perf/metrics/timeline_interaction_record.py

Issue 200843002: Convert smoothness to the new timeline based metric API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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 unified diff | Download patch
OLDNEW
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
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, logical_name, start, end):
50 self.start = event.start 50 assert logical_name
51 self.end = event.end 51 self.logical_name = logical_name
52 self.start = start
53 self.end = end
54 self.is_smooth = False
55 self.is_loading_resources = False
52 56
57 @staticmethod
58 def FromEvent(event):
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 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 logical_name = m.group(1)
64 flags = [] 70 flags = []
65 71
72 record = TimelineInteractionRecord(logical_name, event.start, event.end)
66 for f in flags: 73 for f in flags:
67 if not f in ('is_smooth', 'is_loading_resources'): 74 if not f in ('is_smooth', 'is_loading_resources'):
68 raise Exception( 75 raise Exception(
69 'Unrecognized flag in timeline Interaction record: %s' % f) 76 'Unrecognized flag in timeline Interaction record: %s' % f)
70 self.is_smooth = 'is_smooth' in flags 77 record.is_smooth = 'is_smooth' in flags
71 self.is_loading_resources = 'is_loading_resources' in flags 78 record.is_loading_resources = 'is_loading_resources' in flags
79 return record
72 80
73 def GetResultNameFor(self, result_name): 81 def GetResultNameFor(self, result_name):
74 return "%s/%s" % (self.logical_name, result_name) 82 return "%s-%s" % (self.logical_name, result_name)
OLDNEW
« no previous file with comments | « tools/perf/metrics/timeline_based_metric.py ('k') | tools/perf/metrics/timeline_interaction_record_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698