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

Side by Side Diff: tracing/tracing/value/ui/value_set_table_test.html

Issue 2293533002: Refactor NumericBuilder to HistogramBinBoundaries. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: rebase Created 4 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
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/ui/base/deep_utils.html"> 9 <link rel="import" href="/tracing/ui/base/deep_utils.html">
10 <link rel="import" href="/tracing/value/histogram.html"> 10 <link rel="import" href="/tracing/value/histogram.html">
11 <link rel="import" href="/tracing/value/ui/value_set_table.html"> 11 <link rel="import" href="/tracing/value/ui/value_set_table.html">
12 <link rel="import" href="/tracing/value/value_set.html"> 12 <link rel="import" href="/tracing/value/value_set.html">
13 13
14 <script> 14 <script>
15 'use strict'; 15 'use strict';
16 16
17 tr.b.unittest.testSuite(function() { 17 tr.b.unittest.testSuite(function() {
18 var TEST_NUMERIC_BUILDER = tr.v.NumericBuilder.createLinear( 18 var TEST_BOUNDARIES = tr.v.HistogramBinBoundaries.createLinear(0, 1e3, 20);
19 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter,
20 tr.b.Range.fromExplicitRange(0, 1000), 20);
21 19
22 function getTableRowAtPath(table, path) { 20 function getTableRowAtPath(table, path) {
23 var row = table.tableRows[0]; 21 var row = table.tableRows[0];
24 for (var index of path) 22 for (var index of path)
25 row = row.subRows[index]; 23 row = row.subRows[index];
26 return row; 24 return row;
27 } 25 }
28 26
29 test('instantiate_1x1', function() { 27 test('instantiate_1x1', function() {
30 var table = document.createElement('tr-v-ui-value-set-table'); 28 var table = document.createElement('tr-v-ui-value-set-table');
31 var values = new tr.v.ValueSet(); 29 var values = new tr.v.ValueSet();
32 var numeric = TEST_NUMERIC_BUILDER.build(); 30 var numeric = new tr.v.Histogram(
31 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, TEST_BOUNDARIES);
33 for (var i = 0; i < 100; ++i) 32 for (var i = 0; i < 100; ++i)
34 numeric.add(Math.random() * 1000); 33 numeric.add(Math.random() * 1000);
35 values.addValue(new tr.v.NumericValue('foo', numeric)); 34 values.addValue(new tr.v.NumericValue('foo', numeric));
36 table.values = values; 35 table.values = values;
37 this.addHTMLOutput(table); 36 this.addHTMLOutput(table);
38 var baseTable = tr.b.findDeepElementMatchingPredicate( 37 var baseTable = tr.b.findDeepElementMatchingPredicate(
39 table, elem => elem.tagName === 'TR-UI-B-TABLE'); 38 table, elem => elem.tagName === 'TR-UI-B-TABLE');
40 assert.strictEqual(baseTable.tableRows.length, 1); 39 assert.strictEqual(baseTable.tableRows.length, 1);
41 }); 40 });
42 41
43 // TODO(benjhayden): Test requestSelectionChange. 42 // TODO(benjhayden): Test requestSelectionChange.
44 // TODO(benjhayden): Test search keyup. 43 // TODO(benjhayden): Test search keyup.
45 44
46 test('instantiate_2x2', function() { 45 test('instantiate_2x2', function() {
47 var table = document.createElement('tr-v-ui-value-set-table'); 46 var table = document.createElement('tr-v-ui-value-set-table');
48 var values = new tr.v.ValueSet(); 47 var values = new tr.v.ValueSet();
49 48
50 var numeric0a = TEST_NUMERIC_BUILDER.build(); 49 var numeric0a = new tr.v.Histogram(
50 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, TEST_BOUNDARIES);
51 for (var i = 0; i < 100; ++i) 51 for (var i = 0; i < 100; ++i)
52 numeric0a.add(Math.random() * 1000); 52 numeric0a.add(Math.random() * 1000);
53 var fooA = new tr.v.NumericValue('foo', numeric0a, { 53 var fooA = new tr.v.NumericValue('foo', numeric0a, {
54 description: 'they should have sent a poet' 54 description: 'they should have sent a poet'
55 }); 55 });
56 values.addValue(fooA); 56 values.addValue(fooA);
57 new tr.v.d.IterationInfo({ 57 new tr.v.d.IterationInfo({
58 label: 'iteration A', 58 label: 'iteration A',
59 benchmarkStartMs: new Date().getTime(), 59 benchmarkStartMs: new Date().getTime(),
60 }).addToValue(fooA); 60 }).addToValue(fooA);
61 61
62 var numeric1a = TEST_NUMERIC_BUILDER.build(); 62 var numeric1a = new tr.v.Histogram(
63 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, TEST_BOUNDARIES);
63 for (var i = 0; i < 100; ++i) 64 for (var i = 0; i < 100; ++i)
64 numeric1a.add(Math.random() * 1000); 65 numeric1a.add(Math.random() * 1000);
65 var barA = new tr.v.NumericValue('bar', numeric1a, { 66 var barA = new tr.v.NumericValue('bar', numeric1a, {
66 description: 'indescribable' 67 description: 'indescribable'
67 }); 68 });
68 values.addValue(barA); 69 values.addValue(barA);
69 new tr.v.d.IterationInfo({ 70 new tr.v.d.IterationInfo({
70 label: 'iteration A', 71 label: 'iteration A',
71 benchmarkStartMs: new Date().getTime(), 72 benchmarkStartMs: new Date().getTime(),
72 }).addToValue(barA); 73 }).addToValue(barA);
73 74
74 var numeric0b = TEST_NUMERIC_BUILDER.build(); 75 var numeric0b = new tr.v.Histogram(
76 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, TEST_BOUNDARIES);
75 for (var i = 0; i < 100; ++i) 77 for (var i = 0; i < 100; ++i)
76 numeric0b.add(Math.random() * 1000); 78 numeric0b.add(Math.random() * 1000);
77 var fooB = new tr.v.NumericValue('foo', numeric0b, { 79 var fooB = new tr.v.NumericValue('foo', numeric0b, {
78 description: 'they should have sent a poet' 80 description: 'they should have sent a poet'
79 }); 81 });
80 values.addValue(fooB); 82 values.addValue(fooB);
81 new tr.v.d.IterationInfo({ 83 new tr.v.d.IterationInfo({
82 label: 'iteration B', 84 label: 'iteration B',
83 benchmarkStartMs: new Date().getTime(), 85 benchmarkStartMs: new Date().getTime(),
84 }).addToValue(fooB); 86 }).addToValue(fooB);
85 87
86 var numeric1b = TEST_NUMERIC_BUILDER.build(); 88 var numeric1b = new tr.v.Histogram(
89 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, TEST_BOUNDARIES);
87 for (var i = 0; i < 100; ++i) 90 for (var i = 0; i < 100; ++i)
88 numeric1b.add(Math.random() * 1000); 91 numeric1b.add(Math.random() * 1000);
89 var barB = new tr.v.NumericValue('bar', numeric1b, { 92 var barB = new tr.v.NumericValue('bar', numeric1b, {
90 description: 'indescribable' 93 description: 'indescribable'
91 }); 94 });
92 values.addValue(barB); 95 values.addValue(barB);
93 new tr.v.d.IterationInfo({ 96 new tr.v.d.IterationInfo({
94 label: 'iteration B', 97 label: 'iteration B',
95 benchmarkStartMs: new Date().getTime(), 98 benchmarkStartMs: new Date().getTime(),
96 }).addToValue(barB); 99 }).addToValue(barB);
(...skipping 23 matching lines...) Expand all
120 123
121 for (var benchmarkName of benchmarkNames) { 124 for (var benchmarkName of benchmarkNames) {
122 for (var storyGroupingKey0 of storyGroupingKeys0) { 125 for (var storyGroupingKey0 of storyGroupingKeys0) {
123 for (var storyGroupingKey1 of storyGroupingKeys1) { 126 for (var storyGroupingKey1 of storyGroupingKeys1) {
124 for (var storyName of storyNames) { 127 for (var storyName of storyNames) {
125 for (var startMs of starts) { 128 for (var startMs of starts) {
126 for (var storysetCounter = 0; storysetCounter < 2; 129 for (var storysetCounter = 0; storysetCounter < 2;
127 ++storysetCounter) { 130 ++storysetCounter) {
128 for (var storyCounter = 0; storyCounter < 2; ++storyCounter) { 131 for (var storyCounter = 0; storyCounter < 2; ++storyCounter) {
129 for (var label of labels) { 132 for (var label of labels) {
130 var numeric = TEST_NUMERIC_BUILDER.build(); 133 var numeric = new tr.v.Histogram(
134 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter,
135 TEST_BOUNDARIES);
131 for (var i = 0; i < 100; ++i) 136 for (var i = 0; i < 100; ++i)
132 numeric.add(Math.random() * 1000); 137 numeric.add(Math.random() * 1000);
133 138
134 var value = new tr.v.NumericValue('foo', numeric); 139 var value = new tr.v.NumericValue('foo', numeric);
135 values.addValue(value); 140 values.addValue(value);
136 141
137 new tr.v.d.IterationInfo({ 142 new tr.v.d.IterationInfo({
138 storyGroupingKeys: { 143 storyGroupingKeys: {
139 storyGroupingKey0: storyGroupingKey0, 144 storyGroupingKey0: storyGroupingKey0,
140 storyGroupingKey1: storyGroupingKey1 145 storyGroupingKey1: storyGroupingKey1
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 337 }
333 subRowPath.pop(); 338 subRowPath.pop();
334 } 339 }
335 subRowPath.pop(); 340 subRowPath.pop();
336 } 341 }
337 subRowPath.pop(); 342 subRowPath.pop();
338 } 343 }
339 }); 344 });
340 }); 345 });
341 </script> 346 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/value/ui/scalar_span_test.html ('k') | tracing/tracing/value/ui/value_set_view_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698