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