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

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

Issue 165673008: [telemetry] Implement first version of timeline based measurement (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for landing 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import re
6
7
8 def IsTimelineInteractionRecord(event_name):
9 return event_name.startswith('Interaction.')
10
11
12 class TimelineInteractionRecord(object):
13 """Represents an interaction that took place during a timeline recording.
14
15 As a page runs, typically a number of different (simulated) user interactions
16 take place. For instance, a user might click a button in a mail app causing a
17 popup to animate in. Then they might press another button that sends data to a
18 server and simultaneously closes the popup without an animation. These are two
19 interactions.
20
21 From the point of view of the page, each interaction might have a different
22 logical name: ClickComposeButton and SendEmail, for instance. From the point
23 of view of the benchmarking harness, the names aren't so interesting as what
24 the performance expectations are for that interaction: was it loading
25 resources from the network? was there an animation?
26
27 Determining these things is hard to do, simply by observing the state given to
28 a page from javascript. There are hints, for instance if network requests are
29 sent, or if a CSS animation is pending. But this is by no means a complete
30 story.
31
32 Instead, we expect pages to mark up the timeline what they are doing, with
33 logical names, and flags indicating the semantics of that interaction. This
34 is currently done by pushing markers into the console.time/timeEnd API: this
35 for instance can be issued in JS:
36
37 var str = 'Interaction.SendEmail/is_smooth,is_loading_resources';
38 console.time(str);
39 setTimeout(function() {
40 console.timeEnd(str);
41 }, 1000);
42
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
45 smoothness and network metrics to be reported for the marked up 1000ms
46 time-range.
47
48 """
49 def __init__(self, event):
50 self.start = event.start
51 self.end = event.end
52
53 m = re.match('Interaction\.(.+)\/(.+)', event.name)
54 if m:
55 self.logical_name = m.group(1)
56 if m.group(1) != '':
57 flags = m.group(2).split(',')
58 else:
59 flags = []
60 else:
61 m = re.match('Interaction\.(.+)', event.name)
62 assert m
63 self.logical_name = m.group(1)
64 flags = []
65
66 for f in flags:
67 if not f in ('is_smooth', 'is_loading_resources'):
68 raise Exception(
69 'Unrecognized flag in timeline Interaction record: %s' % f)
70 self.is_smooth = 'is_smooth' in flags
71 self.is_loading_resources = 'is_loading_resources' in flags
72
73 def GetResultNameFor(self, result_name):
74 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