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

Side by Side Diff: tracing/tracing/value/histogram_set.html

Issue 3009553002: Refactor Histogram relationship diagnostics. (Closed)
Patch Set: Created 3 years, 3 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 | « tracing/tracing/value/histogram.py ('k') | tracing/tracing/value/histogram_set.py » ('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/base/utils.html"> 8 <link rel="import" href="/tracing/base/utils.html">
9 <link rel="import" href="/tracing/value/diagnostics/add_related_names.html">
10 <link rel="import" href="/tracing/value/histogram.html"> 9 <link rel="import" href="/tracing/value/histogram.html">
11 <link rel="import" href="/tracing/value/histogram_grouping.html"> 10 <link rel="import" href="/tracing/value/histogram_grouping.html">
12 11
13 <script> 12 <script>
14 'use strict'; 13 'use strict';
15 14
16 tr.exportTo('tr.v', function() { 15 tr.exportTo('tr.v', function() {
17 class HistogramSet { 16 class HistogramSet {
18 constructor(opt_histograms) { 17 constructor(opt_histograms) {
19 this.histogramsByGuid_ = new Map(); 18 this.histogramsByGuid_ = new Map();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 * Lookup a Diagnostic by its guid. 142 * Lookup a Diagnostic by its guid.
144 * 143 *
145 * @param {string} guid 144 * @param {string} guid
146 * @return {!tr.v.d.Diagnostic|undefined} 145 * @return {!tr.v.d.Diagnostic|undefined}
147 */ 146 */
148 lookupDiagnostic(guid) { 147 lookupDiagnostic(guid) {
149 return this.sharedDiagnosticsByGuid_.get(guid); 148 return this.sharedDiagnosticsByGuid_.get(guid);
150 } 149 }
151 150
152 resolveRelatedHistograms() { 151 resolveRelatedHistograms() {
153 const handleDiagnosticMap = dm => {
154 for (const [name, diagnostic] of dm) {
155 if (diagnostic instanceof tr.v.d.RelatedHistogramMap) {
156 diagnostic.resolve(this);
157 }
158 }
159 };
160
161 for (const hist of this) { 152 for (const hist of this) {
162 hist.diagnostics.resolveSharedDiagnostics(this); 153 hist.diagnostics.resolveSharedDiagnostics(this);
163
164 handleDiagnosticMap(hist.diagnostics);
165
166 for (const dm of hist.nanDiagnosticMaps) {
167 handleDiagnosticMap(dm);
168 }
169
170 for (const bin of hist.allBins) {
171 for (const dm of bin.diagnosticMaps) {
172 handleDiagnosticMap(dm);
173 }
174 }
175 } 154 }
176 } 155 }
177 156
178 /** 157 /**
179 * Convert dicts to either Histograms or shared Diagnostics. 158 * Convert dicts to either Histograms or shared Diagnostics.
180 * Does not resolve RelatedHistogramMap diagnostics. See 159 * See resolveRelatedHistograms().
181 * resolveRelatedHistograms().
182 * 160 *
183 * @param {!Object} dicts 161 * @param {!Object} dicts
184 */ 162 */
185 importDicts(dicts) { 163 importDicts(dicts) {
186 for (const dict of dicts) { 164 for (const dict of dicts) {
187 if (dict.type && tr.v.d.Diagnostic.findTypeInfoWithName(dict.type)) { 165 if (dict.type && tr.v.d.Diagnostic.findTypeInfoWithName(dict.type)) {
188 this.sharedDiagnosticsByGuid_.set(dict.guid, 166 this.sharedDiagnosticsByGuid_.set(dict.guid,
189 tr.v.d.Diagnostic.fromDict(dict)); 167 tr.v.d.Diagnostic.fromDict(dict));
190 } else { 168 } else {
191 this.addHistogram(tr.v.Histogram.fromDict(dict)); 169 this.addHistogram(tr.v.Histogram.fromDict(dict));
(...skipping 13 matching lines...) Expand all
205 dicts.push(diagnostic.asDict()); 183 dicts.push(diagnostic.asDict());
206 } 184 }
207 for (const hist of this) { 185 for (const hist of this) {
208 dicts.push(hist.asDict()); 186 dicts.push(hist.asDict());
209 } 187 }
210 return dicts; 188 return dicts;
211 } 189 }
212 190
213 /** 191 /**
214 * Find the Histograms that are not contained in any other Histograms' 192 * Find the Histograms that are not contained in any other Histograms'
215 * RelatedHistogramMap diagnostics. 193 * RelatedNameMap diagnostics.
216 * 194 *
217 * @return {!Array.<!tr.v.Histogram>} 195 * @return {!tr.v.HistogramSet}
218 */ 196 */
219 get sourceHistograms() { 197 get sourceHistograms() {
220 const sourceHistograms = new Map(this.histogramsByGuid_); 198 const diagnosticNames = new Set();
221 // If a Histogram is in a RelatedHistogramMap, 199 for (const hist of this) {
222 // which can be owned either by Histograms or by numeric samples, then it 200 for (const diagnostic of hist.diagnostics.values()) {
223 // is not a source Histogram. 201 if (!(diagnostic instanceof tr.v.d.RelatedNameMap)) continue;
224 function deleteSourceHistograms(diagnosticMap) { 202 for (const name of diagnostic.values()) {
225 for (const [name, diagnostic] of diagnosticMap) { 203 diagnosticNames.add(name);
226 if (diagnostic instanceof tr.v.d.RelatedHistogramMap) {
227 for (const [name, relatedHist] of diagnostic) {
228 sourceHistograms.delete(relatedHist.guid);
229 }
230 } 204 }
231 } 205 }
232 } 206 }
233 207 const sourceHistograms = new HistogramSet();
234 for (const hist of this) { 208 for (const hist of this) {
235 deleteSourceHistograms(hist.diagnostics); 209 if (!diagnosticNames.has(hist.name)) {
236 for (const dm of hist.nanDiagnosticMaps) { 210 sourceHistograms.addHistogram(hist);
237 deleteSourceHistograms(dm);
238 }
239 for (const b of hist.allBins) {
240 for (const dm of b.diagnosticMaps) {
241 deleteSourceHistograms(dm);
242 }
243 } 211 }
244 } 212 }
245 return new HistogramSet([...sourceHistograms.values()]); 213 return sourceHistograms;
246 } 214 }
247 215
248 /** 216 /**
249 * Return a nested Map, whose keys are strings and leaf values are Arrays of 217 * Return a nested Map, whose keys are strings and leaf values are Arrays of
250 * Histograms. 218 * Histograms.
251 * See GROUPINGS for example |groupings|. 219 * See GROUPINGS for example |groupings|.
252 * Groupings are skipped when |opt_skipGroupingCallback| is specified and 220 * Groupings are skipped when |opt_skipGroupingCallback| is specified and
253 * returns true. 221 * returns true.
254 * 222 *
255 * @typedef {!Array.<tr.v.Histogram>} HistogramArray 223 * @typedef {!Array.<tr.v.Histogram>} HistogramArray
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 hist.diagnostics.mergeRelationships(hist); 346 hist.diagnostics.mergeRelationships(hist);
379 } 347 }
380 } 348 }
381 } 349 }
382 350
383 return { 351 return {
384 HistogramSet, 352 HistogramSet,
385 }; 353 };
386 }); 354 });
387 </script> 355 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/value/histogram.py ('k') | tracing/tracing/value/histogram_set.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698