OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2015 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2015 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/statistics.html"> | 8 <link rel="import" href="/tracing/base/math/statistics.html"> |
9 <link rel="import" href="/tracing/ui/base/box_chart.html"> | 9 <link rel="import" href="/tracing/ui/base/box_chart.html"> |
10 <link rel="import" href="/tracing/ui/base/drag_handle.html"> | 10 <link rel="import" href="/tracing/ui/base/drag_handle.html"> |
11 <link rel="import" href="/tracing/ui/base/name_bar_chart.html"> | 11 <link rel="import" href="/tracing/ui/base/name_bar_chart.html"> |
12 <link rel="import" href="/tracing/value/ui/diagnostic_map_table.html"> | 12 <link rel="import" href="/tracing/value/ui/diagnostic_map_table.html"> |
13 <link rel="import" href="/tracing/value/ui/diagnostic_span.html"> | 13 <link rel="import" href="/tracing/value/ui/diagnostic_span.html"> |
14 <link rel="import" href="/tracing/value/ui/scalar_map_table.html"> | 14 <link rel="import" href="/tracing/value/ui/scalar_map_table.html"> |
15 | 15 |
16 <dom-module id='tr-v-ui-histogram-span'> | 16 <dom-module id='tr-v-ui-histogram-span'> |
17 <template> | 17 <template> |
18 <style> | 18 <style> |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 return 300; | 192 return 300; |
193 }, | 193 }, |
194 | 194 |
195 get brushedBins() { | 195 get brushedBins() { |
196 return this.brushedBins_; | 196 return this.brushedBins_; |
197 }, | 197 }, |
198 | 198 |
199 set brushedBins(bins) { | 199 set brushedBins(bins) { |
200 this.brushedBins_ = bins; | 200 this.brushedBins_ = bins; |
201 let brushedBinIndices = new tr.b.Range(); | 201 let brushedBinIndices = new tr.b.math.Range(); |
202 for (let bin of bins) { | 202 for (let bin of bins) { |
203 brushedBinIndices.addValue(this.histogram.allBins.indexOf(bin)); | 203 brushedBinIndices.addValue(this.histogram.allBins.indexOf(bin)); |
204 } | 204 } |
205 this.chart_.brushedRange = brushedBinIndices; | 205 this.chart_.brushedRange = brushedBinIndices; |
206 this.updateDiagnostics_(); | 206 this.updateDiagnostics_(); |
207 }, | 207 }, |
208 | 208 |
209 updateBrushedRange_(binIndex) { | 209 updateBrushedRange_(binIndex) { |
210 let brushedBinIndices = new tr.b.Range(); | 210 let brushedBinIndices = new tr.b.math.Range(); |
211 brushedBinIndices.addValue(tr.b.clamp( | 211 brushedBinIndices.addValue(tr.b.math.clamp( |
212 this.mouseDownBinIndex_, 0, this.histogram.allBins.length - 1)); | 212 this.mouseDownBinIndex_, 0, this.histogram.allBins.length - 1)); |
213 brushedBinIndices.addValue(tr.b.clamp( | 213 brushedBinIndices.addValue(tr.b.math.clamp( |
214 binIndex, 0, this.histogram.allBins.length - 1)); | 214 binIndex, 0, this.histogram.allBins.length - 1)); |
215 brushedBinIndices.max += 1; | 215 brushedBinIndices.max += 1; |
216 this.chart_.brushedRange = brushedBinIndices; | 216 this.chart_.brushedRange = brushedBinIndices; |
217 | 217 |
218 this.brushedBins_ = []; | 218 this.brushedBins_ = []; |
219 for (let i = brushedBinIndices.min; i < brushedBinIndices.max; ++i) { | 219 for (let i = brushedBinIndices.min; i < brushedBinIndices.max; ++i) { |
220 this.brushedBins.push(this.histogram.allBins[i]); | 220 this.brushedBins.push(this.histogram.allBins[i]); |
221 } | 221 } |
222 }, | 222 }, |
223 | 223 |
(...skipping 18 matching lines...) Expand all Loading... |
242 onMouseUp_(chartEvent) { | 242 onMouseUp_(chartEvent) { |
243 chartEvent.stopPropagation(); | 243 chartEvent.stopPropagation(); |
244 if (!this.histogram) { | 244 if (!this.histogram) { |
245 return; | 245 return; |
246 } | 246 } |
247 this.updateBrushedRange_(chartEvent.y); | 247 this.updateBrushedRange_(chartEvent.y); |
248 if (this.prevBrushedBins_.length === 1 && | 248 if (this.prevBrushedBins_.length === 1 && |
249 this.brushedBins_.length === 1 && | 249 this.brushedBins_.length === 1 && |
250 this.prevBrushedBins_[0] === this.brushedBins_[0]) { | 250 this.prevBrushedBins_[0] === this.brushedBins_[0]) { |
251 this.brushedBins_ = []; | 251 this.brushedBins_ = []; |
252 this.chart_.brushedRange = new tr.b.Range(); | 252 this.chart_.brushedRange = new tr.b.math.Range(); |
253 } | 253 } |
254 this.updateDiagnostics_(); | 254 this.updateDiagnostics_(); |
255 this.mouseDownBinIndex_ = undefined; | 255 this.mouseDownBinIndex_ = undefined; |
256 }, | 256 }, |
257 | 257 |
258 updateDiagnostics_() { | 258 updateDiagnostics_() { |
259 let maps = []; | 259 let maps = []; |
260 for (let bin of this.brushedBins) { | 260 for (let bin of this.brushedBins) { |
261 for (let map of bin.diagnosticMaps) { | 261 for (let map of bin.diagnosticMaps) { |
262 maps.push(map); | 262 maps.push(map); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 if (histogram === this.referenceHistogram_) { | 299 if (histogram === this.referenceHistogram_) { |
300 return; | 300 return; |
301 } | 301 } |
302 this.referenceHistogram_ = histogram; | 302 this.referenceHistogram_ = histogram; |
303 if (this.histogram) this.updateContents_(); | 303 if (this.histogram) this.updateContents_(); |
304 }, | 304 }, |
305 | 305 |
306 getDeltaScalars_(statNames, scalarMap) { | 306 getDeltaScalars_(statNames, scalarMap) { |
307 if (!this.histogram.canCompare(this.referenceHistogram)) return; | 307 if (!this.histogram.canCompare(this.referenceHistogram)) return; |
308 | 308 |
309 let mwu = tr.b.Statistics.mwu( | 309 let mwu = tr.b.math.Statistics.mwu( |
310 this.histogram.sampleValues, this.referenceHistogram.sampleValues); | 310 this.histogram.sampleValues, this.referenceHistogram.sampleValues); |
311 | 311 |
312 for (let deltaStatName of tr.v.Histogram.getDeltaStatisticsNames( | 312 for (let deltaStatName of tr.v.Histogram.getDeltaStatisticsNames( |
313 statNames)) { | 313 statNames)) { |
314 if (IGNORE_DELTA_STATISTICS_NAMES.includes(deltaStatName)) continue; | 314 if (IGNORE_DELTA_STATISTICS_NAMES.includes(deltaStatName)) continue; |
315 let scalar = this.histogram.getStatisticScalar( | 315 let scalar = this.histogram.getStatisticScalar( |
316 deltaStatName, this.referenceHistogram, mwu); | 316 deltaStatName, this.referenceHistogram, mwu); |
317 if (scalar === undefined) continue; | 317 if (scalar === undefined) continue; |
318 scalarMap.set(deltaStatName, scalar); | 318 scalarMap.set(deltaStatName, scalar); |
319 } | 319 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 this.chart_.graphHeight = this.graphHeight; | 407 this.chart_.graphHeight = this.graphHeight; |
408 this.chart_.addEventListener('item-mousedown', | 408 this.chart_.addEventListener('item-mousedown', |
409 this.onMouseDown_.bind(this)); | 409 this.onMouseDown_.bind(this)); |
410 this.chart_.addEventListener('item-mousemove', | 410 this.chart_.addEventListener('item-mousemove', |
411 this.onMouseMove_.bind(this)); | 411 this.onMouseMove_.bind(this)); |
412 this.chart_.addEventListener('item-mouseup', | 412 this.chart_.addEventListener('item-mouseup', |
413 this.onMouseUp_.bind(this)); | 413 this.onMouseUp_.bind(this)); |
414 this.chart_.hideLegend = true; | 414 this.chart_.hideLegend = true; |
415 this.chart_.getDataSeries('y').color = 'blue'; | 415 this.chart_.getDataSeries('y').color = 'blue'; |
416 this.chart_.xAxisLabel = '#'; | 416 this.chart_.xAxisLabel = '#'; |
417 this.chart_.brushedRange = new tr.b.Range(); | 417 this.chart_.brushedRange = new tr.b.math.Range(); |
418 | 418 |
419 let chartData = []; | 419 let chartData = []; |
420 let binCounts = []; | 420 let binCounts = []; |
421 for (let bin of this.histogram.allBins) { | 421 for (let bin of this.histogram.allBins) { |
422 let x = bin.range.min; | 422 let x = bin.range.min; |
423 if (x === -Number.MAX_VALUE) { | 423 if (x === -Number.MAX_VALUE) { |
424 x = '<' + new tr.b.Scalar( | 424 x = '<' + new tr.b.Scalar( |
425 this.histogram.unit, bin.range.max).toString(); | 425 this.histogram.unit, bin.range.max).toString(); |
426 } else { | 426 } else { |
427 x = new tr.b.Scalar(this.histogram.unit, x).toString(); | 427 x = new tr.b.Scalar(this.histogram.unit, x).toString(); |
428 } | 428 } |
429 chartData.push({x: x, y: bin.count}); | 429 chartData.push({x: x, y: bin.count}); |
430 binCounts.push(bin.count); | 430 binCounts.push(bin.count); |
431 } | 431 } |
432 | 432 |
433 // If the largest 1 or 2 bins are more than twice as large as the next | 433 // If the largest 1 or 2 bins are more than twice as large as the next |
434 // largest bin, then set the dataRange max to TRUNCATE_BIN_MARGIN% more | 434 // largest bin, then set the dataRange max to TRUNCATE_BIN_MARGIN% more |
435 // than that next largest bin. | 435 // than that next largest bin. |
436 binCounts.sort((x, y) => y - x); | 436 binCounts.sort((x, y) => y - x); |
437 let dataRange = tr.b.Range.fromExplicitRange(0, binCounts[0]); | 437 let dataRange = tr.b.math.Range.fromExplicitRange(0, binCounts[0]); |
438 if (binCounts[1] > 0 && binCounts[0] > (binCounts[1] * 2)) { | 438 if (binCounts[1] > 0 && binCounts[0] > (binCounts[1] * 2)) { |
439 dataRange.max = binCounts[1] * (1 + TRUNCATE_BIN_MARGIN); | 439 dataRange.max = binCounts[1] * (1 + TRUNCATE_BIN_MARGIN); |
440 } | 440 } |
441 if (binCounts[2] > 0 && binCounts[1] > (binCounts[2] * 2)) { | 441 if (binCounts[2] > 0 && binCounts[1] > (binCounts[2] * 2)) { |
442 dataRange.max = binCounts[2] * (1 + TRUNCATE_BIN_MARGIN); | 442 dataRange.max = binCounts[2] * (1 + TRUNCATE_BIN_MARGIN); |
443 } | 443 } |
444 this.chart_.overrideDataRange = dataRange; | 444 this.chart_.overrideDataRange = dataRange; |
445 | 445 |
446 this.chart_.data = chartData; | 446 this.chart_.data = chartData; |
447 } | 447 } |
448 }); | 448 }); |
449 }); | 449 }); |
450 </script> | 450 </script> |
OLD | NEW |