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

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

Issue 2428953002: Helper function for get interactive timestamps (Closed)
Patch Set: 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
35 function getInteractiveTimestamps(model) {
36 // TODO(dproy): When LoadExpectation v.1.0 is released,
37 // update this function to use the new LoadExpectation rather
38 // than calling loading_metric.html.
39
40 var values = new tr.v.ValueSet();
41 tr.metrics.sh.loadingMetric(values, model);
42 var ttiValues = values.getValuesNamed('timeToFirstInteractive');
43 var interactiveTimestamps = [];
44 for (var bin of tr.b.getOnlyElement(ttiValues).allBins) {
45 for (var diagnostics of bin.diagnosticMaps) {
46 var info = diagnostics.get('Navigation infos');
47 interactiveTimestamps.push(info.value.interactive);
48 }
49 }
50 return interactiveTimestamps;
nednguyen 2016/10/18 19:56:11 Hmhh, this is a flatten list, which will not work
dproy 2016/10/18 20:44:59 You're right. Fixed in latest patch.
51 }
52
32 /** 53 /**
33 * Returns an Array of task windows that start with the supplied interactive 54 * Returns an Array of task windows that start with the supplied interactive
34 * timestamps. 55 * timestamps.
35 * 56 *
36 * A task window is defined as the range of time from the time when the page 57 * A task window is defined as the range of time from the time when the page
37 * became interactive until either 58 * became interactive until either
38 * 59 *
39 * 1. The beginning of the next navigationStart event or 60 * 1. The beginning of the next navigationStart event or
40 * 2. The end of the trace 61 * 2. The end of the trace
41 * 62 *
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 99
79 taskWindows.push(tr.b.Range.fromExplicitRange( 100 taskWindows.push(tr.b.Range.fromExplicitRange(
80 currTTI, taskWindowEndTs)); 101 currTTI, taskWindowEndTs));
81 lastTaskWindowEndTs = taskWindowEndTs; 102 lastTaskWindowEndTs = taskWindowEndTs;
82 } 103 }
83 return taskWindows; 104 return taskWindows;
84 } 105 }
85 106
86 return { 107 return {
87 getPostInteractiveTaskWindows: getPostInteractiveTaskWindows, 108 getPostInteractiveTaskWindows: getPostInteractiveTaskWindows,
88 getNavStartTimestamps: getNavStartTimestamps 109 getNavStartTimestamps: getNavStartTimestamps,
110 getInteractiveTimestamps: getInteractiveTimestamps
89 }; 111 };
90 }); 112 });
91 </script> 113 </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