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

Side by Side Diff: tracing/tracing/extras/chrome/estimated_input_latency.html

Issue 2428953002: Helper function for get interactive timestamps (Closed)
Patch Set: Address charliea@ comments Created 4 years, 2 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
« no previous file with comments | « no previous file | tracing/tracing/extras/chrome/estimated_input_latency_test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2016 The Chromium Authors. All rights reserved. 3 Copyright 2016 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/metrics/system_health/loading_metric.html">
9 <link rel="import" href="/tracing/value/value_set.html">
10
8 <script> 11 <script>
9 'use strict'; 12 'use strict';
10 tr.exportTo('tr.e.chrome', function() { 13 tr.exportTo('tr.e.chrome', function() {
11 14
12 // TODO(dproy): Because title and category are properties of TimedEvent 15 // TODO(dproy): Because title and category are properties of TimedEvent
13 // subclasses and not TimedEvent itself, we have to write our own "has title 16 // subclasses and not TimedEvent itself, we have to write our own "has title
14 // and category" function rather than having it provided by TimedEvent. 17 // and category" function rather than having it provided by TimedEvent.
15 // This should be fixed. 18 // This should be fixed.
16 // https://github.com/catapult-project/catapult/issues/2784 19 // https://github.com/catapult-project/catapult/issues/2784
17 function hasTitleAndCategory(event, title, category) { 20 function hasTitleAndCategory(event, title, category) {
18 return event.title === title && event.category && 21 return event.title === title && event.category &&
19 tr.b.getCategoryParts(event.category).indexOf(category) !== -1; 22 tr.b.getCategoryParts(event.category).indexOf(category) !== -1;
20 } 23 }
21 24
22 function getNavStartTimestamps(rendererHelper) { 25 function getNavStartTimestamps(rendererHelper) {
23 var navStartTimestamps = []; 26 var navStartTimestamps = [];
24 for (var e of rendererHelper.mainThread.sliceGroup.childEvents()) { 27 for (var e of rendererHelper.mainThread.sliceGroup.childEvents()) {
25 if (hasTitleAndCategory(e, 'navigationStart', 'blink.user_timing')) { 28 if (hasTitleAndCategory(e, 'navigationStart', 'blink.user_timing')) {
26 navStartTimestamps.push(e.start); 29 navStartTimestamps.push(e.start);
27 } 30 }
28 } 31 }
29 return navStartTimestamps; 32 return navStartTimestamps;
30 } 33 }
31 34
32 /** 35 /**
36 * Returns a map of renderer PIDs to array of timestamps at which the
37 * renderer became interactive.
38 */
39 function getInteractiveTimestamps(model) {
40 // TODO(dproy): When LoadExpectation v.1.0 is released,
41 // update this function to use the new LoadExpectation rather
42 // than calling loading_metric.html.
43
44 var values = new tr.v.ValueSet();
45 tr.metrics.sh.loadingMetric(values, model);
46 var ttiValues = values.getValuesNamed('timeToFirstInteractive');
47 var interactiveTimestampsMap = new Map();
48 for (var bin of tr.b.getOnlyElement(ttiValues).allBins) {
49 for (var diagnostics of bin.diagnosticMaps) {
50 var value = diagnostics.get('Navigation infos').value;
51 var pid = value.pid;
52 var interactiveTimestampsForProcess =
53 interactiveTimestampsMap.get(pid) || [];
54 interactiveTimestampsForProcess.push(value.interactive);
55 interactiveTimestampsMap.set(pid, interactiveTimestampsForProcess);
56 }
57 }
58 return interactiveTimestampsMap;
59 }
60
61 /**
33 * Returns an Array of task windows that start with the supplied interactive 62 * Returns an Array of task windows that start with the supplied interactive
34 * timestamps. 63 * timestamps.
35 * 64 *
36 * A task window is defined as the range of time from the time when the page 65 * A task window is defined as the range of time from the time when the page
37 * became interactive until either 66 * became interactive until either
38 * 67 *
39 * 1. The beginning of the next navigationStart event or 68 * 1. The beginning of the next navigationStart event or
40 * 2. The end of the trace 69 * 2. The end of the trace
41 * 70 *
42 * This function only works when timestamps are from the same renderer. If 71 * This function only works when timestamps are from the same renderer. If
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 107
79 taskWindows.push(tr.b.Range.fromExplicitRange( 108 taskWindows.push(tr.b.Range.fromExplicitRange(
80 currTTI, taskWindowEndTs)); 109 currTTI, taskWindowEndTs));
81 lastTaskWindowEndTs = taskWindowEndTs; 110 lastTaskWindowEndTs = taskWindowEndTs;
82 } 111 }
83 return taskWindows; 112 return taskWindows;
84 } 113 }
85 114
86 return { 115 return {
87 getPostInteractiveTaskWindows: getPostInteractiveTaskWindows, 116 getPostInteractiveTaskWindows: getPostInteractiveTaskWindows,
88 getNavStartTimestamps: getNavStartTimestamps 117 getNavStartTimestamps: getNavStartTimestamps,
118 getInteractiveTimestamps: getInteractiveTimestamps
89 }; 119 };
90 }); 120 });
91 </script> 121 </script>
OLDNEW
« no previous file with comments | « no previous file | tracing/tracing/extras/chrome/estimated_input_latency_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698