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

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

Issue 2804693005: Getting segments for rail stage and initiator (Closed)
Patch Set: Address comments by tdresser@ Created 3 years, 7 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/cpu_time_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 2017 The Chromium Authors. All rights reserved. 3 Copyright 2017 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/base/multi_dimensional_view.html"> 8 <link rel="import" href="/tracing/base/multi_dimensional_view.html">
9 <link rel="import" href="/tracing/model/helpers/chrome_model_helper.html"> 9 <link rel="import" href="/tracing/model/helpers/chrome_model_helper.html">
10 <link rel="import" href="/tracing/model/helpers/chrome_renderer_helper.html"> 10 <link rel="import" href="/tracing/model/helpers/chrome_renderer_helper.html">
(...skipping 22 matching lines...) Expand all
33 // We assume that if a slice doesn't lie entirely inside the range of 33 // We assume that if a slice doesn't lie entirely inside the range of
34 // interest, then the CPU time is evenly distributed inside of the 34 // interest, then the CPU time is evenly distributed inside of the
35 // slice. 35 // slice.
36 totalCpuTime += 36 totalCpuTime +=
37 slice.cpuDuration * fractionOfSliceInsideRangeOfInterest; 37 slice.cpuDuration * fractionOfSliceInsideRangeOfInterest;
38 }); 38 });
39 39
40 return totalCpuTime; 40 return totalCpuTime;
41 } 41 }
42 42
43 /**
44 * Returns two level map of rail stage to initiator type to set of bounds of
45 * associated segments, intersected with |rangeOfInterest|.
46 *
47 * For each rail stage, we additionally have a key 'all_initiators' that
48 * returns all the segment bounds associated with that rail stage across all
49 * initiator types. For completeness, there is an additional rail stage
50 * 'all_stages' that has all the segment bounds across all rail stages.
51 *
52 * If a segment is not contained within |rangeOfInterest| it is not included.
53 *
54 * There is a unique segment bound for each segment in the map. For example,
55 * assume
56 * - |segmentA| is associated with both Click Response and Scroll Animation
57 * - |bound1| is the interesting bound of |segmentA| in Response -> Click set.
58 * - |bound2| is the interesting bound of |segmentA| in Animation -> Scroll
59 set.
60 * Then bound1 === bound2. These segment bounds can therefore be used as keys
61 * in a map to represent the segment.
62 *
63 * Example return value (all bounds are intersected with |rangeOfInterest|):
64 *
65 * {
66 * 'Animation': {
67 * 'CSS': {Segment bounds for CSS Animation},
68 * 'Video': {Segment bounds for Video Animation},
69 * ...
70 * 'all_initiators': {All Animation segment bounds}
71 * },
72 * 'Response': {
73 * 'Click': {Segment bounds for Click Response},
74 * 'Scroll': {Segment bounds for Scroll Response},
75 * ...
76 * 'all_initiators': {All Response segment bounds}
77 * },
78 * ...
79 * 'all_stages': {
80 * 'all_initiators': {All segment bounds}
81 * }
82 * }
83 *
84 * @param {!Array.<!tr.model.um.Segment>} segments
85 * @param {!Array.<!tr.b.math.Range>} rangeOfInterest
86 * @returns {!Map.<string, Map.<string, Set.<!tr.b.math.Range>>}
87 */
88 function getStageToInitiatorToSegmentBounds(segments, rangeOfInterest) {
89 const stageToInitiatorToRanges = new Map();
90 stageToInitiatorToRanges.set('all_stages',
91 new Map([['all_initiators', new Set()]]));
92 const allRanges =
93 stageToInitiatorToRanges.get('all_stages').get('all_initiators');
94
95 for (const segment of segments) {
96 if (!rangeOfInterest.intersectsRangeInclusive(segment.range)) continue;
97 const intersectingRange = rangeOfInterest.findIntersection(segment.range);
98 allRanges.add(intersectingRange);
99
100 for (const expectation of segment.expectations) {
101 const stageTitle = expectation.stageTitle;
102 if (!stageToInitiatorToRanges.has(stageTitle)) {
103 stageToInitiatorToRanges.set(stageTitle,
104 new Map([['all_initiators', new Set()]]));
105 }
106
107 const initiatorToRanges = stageToInitiatorToRanges.get(stageTitle);
108 initiatorToRanges.get('all_initiators').add(intersectingRange);
109
110 const initiatorType = expectation.initiatorType;
111 if (initiatorType) {
112 if (!initiatorToRanges.has(initiatorType)) {
113 initiatorToRanges.set(initiatorType, new Set());
114 }
115 initiatorToRanges.get(initiatorType).add(intersectingRange);
116 }
117 }
118 }
119 return stageToInitiatorToRanges;
120 }
121
43 return { 122 return {
44 getCpuTimeForThread, 123 getCpuTimeForThread,
124 getStageToInitiatorToSegmentBounds,
45 }; 125 };
46 }); 126 });
47 </script> 127 </script>
OLDNEW
« no previous file with comments | « no previous file | tracing/tracing/extras/chrome/cpu_time_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698