OLD | NEW |
---|---|
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 Loading... | |
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> |
OLD | NEW |