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/base/fixed_color_scheme.html"> | 8 <link rel="import" href="/tracing/base/fixed_color_scheme.html"> |
9 <link rel="import" href="/tracing/ui/base/deep_utils.html"> | 9 <link rel="import" href="/tracing/ui/base/deep_utils.html"> |
10 <link rel="import" href="/tracing/value/diagnostics/breakdown.html"> | 10 <link rel="import" href="/tracing/value/diagnostics/breakdown.html"> |
11 <link rel="import" href="/tracing/value/diagnostics/related_histogram_breakdown.
html"> | |
12 <link rel="import" href="/tracing/value/histogram.html"> | 11 <link rel="import" href="/tracing/value/histogram.html"> |
13 <link rel="import" href="/tracing/value/ui/breakdown_span.html"> | 12 <link rel="import" href="/tracing/value/ui/breakdown_span.html"> |
14 <link rel="import" href="/tracing/value/ui/diagnostic_span.html"> | 13 <link rel="import" href="/tracing/value/ui/diagnostic_span.html"> |
15 | 14 |
16 <script> | 15 <script> |
17 'use strict'; | 16 'use strict'; |
18 | 17 |
19 tr.b.unittest.testSuite(function() { | 18 tr.b.unittest.testSuite(function() { |
20 test('instantiate_RelatedHistogramBreakdown', function() { | |
21 const breakdown = new tr.v.d.RelatedHistogramBreakdown(); | |
22 | |
23 const qux = new tr.v.Histogram('qux', tr.b.Unit.byName.timeDurationInMs); | |
24 qux.addSample(1); | |
25 breakdown.add(qux); | |
26 | |
27 // The title of the analysis-link should match the histogram name, not the | |
28 // breakdown key. | |
29 const foo = new tr.v.Histogram('foo', tr.b.Unit.byName.timeDurationInMs); | |
30 breakdown.set('f', foo); | |
31 | |
32 const bar = new tr.v.Histogram('bar', tr.b.Unit.byName.timeDurationInMs); | |
33 breakdown.add(bar); | |
34 | |
35 for (let i = 0; i < 1e2; ++i) { | |
36 foo.addSample(i); | |
37 bar.addSample(i); | |
38 } | |
39 | |
40 const span = tr.v.ui.createDiagnosticSpan(breakdown, '', new tr.v.Histogram( | |
41 '', tr.b.Unit.byName.timeDurationInMs)); | |
42 assert.strictEqual('TR-V-UI-BREAKDOWN-SPAN', span.tagName); | |
43 this.addHTMLOutput(span); | |
44 assert.isDefined(tr.ui.b.findDeepElementMatchingPredicate( | |
45 span, e => e.textContent === '9,901.000 ms')); | |
46 assert.isDefined(tr.ui.b.findDeepElementMatchingPredicate( | |
47 span, e => e.textContent === '4,950.000 ms')); | |
48 assert.isDefined(tr.ui.b.findDeepElementMatchingPredicate( | |
49 span, e => e.textContent === '8,000.000 ms')); | |
50 }); | |
51 | |
52 test('instantiate_Breakdown', function() { | 19 test('instantiate_Breakdown', function() { |
53 let breakdown = new tr.v.d.Breakdown(); | 20 let breakdown = new tr.v.d.Breakdown(); |
54 breakdown.colorScheme = | 21 breakdown.colorScheme = |
55 tr.v.d.COLOR_SCHEME_CHROME_USER_FRIENDLY_CATEGORY_DRIVER; | 22 tr.v.d.COLOR_SCHEME_CHROME_USER_FRIENDLY_CATEGORY_DRIVER; |
56 breakdown.set('script', 42); | 23 breakdown.set('script', 42); |
57 breakdown.set('style', 57); | 24 breakdown.set('style', 57); |
58 | 25 |
59 // Test weird numbers. | 26 // Test weird numbers. |
60 breakdown.set('ba---a', NaN); | 27 breakdown.set('ba---a', NaN); |
61 breakdown.set('inf', Infinity); | 28 breakdown.set('inf', Infinity); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 breakdown.set('ba---a', NaN); | 79 breakdown.set('ba---a', NaN); |
113 breakdown.set('inf', Infinity); | 80 breakdown.set('inf', Infinity); |
114 breakdown.set('-inf', -Infinity); | 81 breakdown.set('-inf', -Infinity); |
115 breakdown.set('goose egg', 0); | 82 breakdown.set('goose egg', 0); |
116 breakdown.set('<0', -1); | 83 breakdown.set('<0', -1); |
117 | 84 |
118 const span = tr.v.ui.createDiagnosticSpan(breakdown); | 85 const span = tr.v.ui.createDiagnosticSpan(breakdown); |
119 assert.strictEqual('TR-V-UI-BREAKDOWN-SPAN', span.tagName); | 86 assert.strictEqual('TR-V-UI-BREAKDOWN-SPAN', span.tagName); |
120 this.addHTMLOutput(span); | 87 this.addHTMLOutput(span); |
121 }); | 88 }); |
| 89 |
| 90 test('correlate', function() { |
| 91 const histograms = new tr.v.HistogramSet(); |
| 92 const sample0Breakdown = new tr.v.d.Breakdown(); |
| 93 sample0Breakdown.set('a', 5); |
| 94 sample0Breakdown.set('b', 3); |
| 95 sample0Breakdown.set('c', 2); |
| 96 const sample1Breakdown = new tr.v.d.Breakdown(); |
| 97 sample1Breakdown.set('a', 50); |
| 98 sample1Breakdown.set('b', 30); |
| 99 sample1Breakdown.set('c', 20); |
| 100 const related = new tr.v.d.RelatedNameMap(); |
| 101 related.set('a', histograms.createHistogram('root:a', |
| 102 tr.b.Unit.byName.timeDurationInMs, [5, 50]).name); |
| 103 related.set('b', tr.v.Histogram.create('root:b', |
| 104 tr.b.Unit.byName.timeDurationInMs, [3, 30]).name); |
| 105 related.set('c', tr.v.Histogram.create('root:c', |
| 106 tr.b.Unit.byName.timeDurationInMs, [2, 20]).name); |
| 107 const hist = histograms.createHistogram('root', |
| 108 tr.b.Unit.byName.timeDurationInMs, [ |
| 109 { |
| 110 value: 10, |
| 111 diagnostics: new Map([['breakdown', sample0Breakdown]]), |
| 112 }, |
| 113 { |
| 114 value: 100, |
| 115 diagnostics: new Map([['breakdown', sample1Breakdown]]), |
| 116 }, |
| 117 ], { |
| 118 diagnostics: new Map([ |
| 119 ['breakdown', related], |
| 120 ]), |
| 121 }); |
| 122 const span = tr.v.ui.createDiagnosticSpan(sample0Breakdown, 'breakdown', |
| 123 hist); |
| 124 this.addHTMLOutput(span); |
| 125 const links = tr.ui.b.findDeepElementsMatching(span, |
| 126 'tr-ui-a-analysis-link'); |
| 127 assert.lengthOf(links, 4); |
| 128 assert.strictEqual(links[0].title, ''); |
| 129 assert.strictEqual(links[1].title, 'root:a'); |
| 130 assert.strictEqual(links[2].title, 'root:b'); |
| 131 assert.strictEqual(links[3].title, 'root:c'); |
| 132 assert.strictEqual(links[0].textContent, 'Select All'); |
| 133 assert.strictEqual(links[1].textContent, 'a'); |
| 134 assert.strictEqual(links[2].textContent, 'b'); |
| 135 assert.strictEqual(links[3].textContent, 'c'); |
| 136 assert.lengthOf(links[0].selection, 3); |
| 137 assert.strictEqual(links[0].selection[0], 'root:a'); |
| 138 assert.strictEqual(links[0].selection[1], 'root:b'); |
| 139 assert.strictEqual(links[0].selection[2], 'root:c'); |
| 140 assert.lengthOf(links[1].selection, 1); |
| 141 assert.strictEqual(links[1].selection[0], 'root:a'); |
| 142 assert.lengthOf(links[2].selection, 1); |
| 143 assert.strictEqual(links[2].selection[0], 'root:b'); |
| 144 assert.lengthOf(links[3].selection, 1); |
| 145 assert.strictEqual(links[3].selection[0], 'root:c'); |
| 146 }); |
122 }); | 147 }); |
123 </script> | 148 </script> |
OLD | NEW |