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

Side by Side Diff: tracing/tracing/value/value_set_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
« no previous file with comments | « tracing/tracing/value/ui/value_set_view_test.html ('k') | no next file » | 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/range.html"> 8 <link rel="import" href="/tracing/base/range.html">
9 <link rel="import" href="/tracing/value/diagnostics/diagnostic_map.html"> 9 <link rel="import" href="/tracing/value/diagnostics/diagnostic_map.html">
10 <link rel="import" href="/tracing/value/diagnostics/generic.html"> 10 <link rel="import" href="/tracing/value/diagnostics/generic.html">
11 <link rel="import" href="/tracing/value/histogram.html"> 11 <link rel="import" href="/tracing/value/histogram.html">
12 <link rel="import" href="/tracing/value/unit.html"> 12 <link rel="import" href="/tracing/value/unit.html">
13 <link rel="import" href="/tracing/value/value_set.html"> 13 <link rel="import" href="/tracing/value/value_set.html">
14 14
15 <script> 15 <script>
16 'use strict'; 16 'use strict';
17 17
18 tr.b.unittest.testSuite(function() { 18 tr.b.unittest.testSuite(function() {
19 test('addValuesFromDicts', function() { 19 test('addValuesFromDicts', function() {
20 var n = tr.v.NumericBuilder.createLinear( 20 var n = new tr.v.Histogram(tr.v.Unit.byName.unitlessNumber);
21 tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 100),
22 100).build();
23 n.add(10); 21 n.add(10);
24 n.customizeSummaryOptions({ 22 n.customizeSummaryOptions({
25 count: true, 23 count: true,
26 min: false, 24 min: false,
27 max: false, 25 max: false,
28 sum: true, 26 sum: true,
29 avg: false, 27 avg: false,
30 std: false 28 std: false
31 }); 29 });
32 30
33 var values = new tr.v.ValueSet([new tr.v.NumericValue('foo', n)]); 31 var values = new tr.v.ValueSet([new tr.v.NumericValue('foo', n)]);
34 var values2 = new tr.v.ValueSet(); 32 var values2 = new tr.v.ValueSet();
35 values2.addValuesFromDicts(values.valueDicts); 33 values2.addValuesFromDicts(values.valueDicts);
36 // foo, foo_count, foo_sum 34 // foo, foo_count, foo_sum
37 assert.lengthOf(values2.getValuesWithName('foo'), 3); 35 assert.lengthOf(values2.getValuesWithName('foo'), 3);
38 assert.lengthOf(values2.getValuesNamed('foo'), 1); 36 assert.lengthOf(values2.getValuesNamed('foo'), 1);
39 }); 37 });
40 38
41 test('addValueFromDictsWithSampleDiagnostic', function() { 39 test('addValueFromDictsWithSampleDiagnostic', function() {
42 var n = tr.v.NumericBuilder.createLinear( 40 var n = new tr.v.Histogram(tr.v.Unit.byName.count);
43 tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 100),
44 100).build();
45 n.add(10, tr.v.d.DiagnosticMap.fromObject({ 41 n.add(10, tr.v.d.DiagnosticMap.fromObject({
46 bar: new tr.v.d.Generic('baz') 42 bar: new tr.v.d.Generic('baz')
47 })); 43 }));
48 44
49 var values = new tr.v.ValueSet([new tr.v.NumericValue('foo', n)]); 45 var values = new tr.v.ValueSet([new tr.v.NumericValue('foo', n)]);
50 var values2 = new tr.v.ValueSet(); 46 var values2 = new tr.v.ValueSet();
51 values2.addValuesFromDicts(values.valueDicts); 47 values2.addValuesFromDicts(values.valueDicts);
52 assert.lengthOf(values2.getValuesNamed('foo'), 1); 48 assert.lengthOf(values2.getValuesNamed('foo'), 1);
53 var v = values2.getValuesNamed('foo')[0]; 49 var v = values2.getValuesNamed('foo')[0];
54 assert.lengthOf(v.numeric.getBinForValue(10).diagnosticMaps, 1); 50 assert.lengthOf(v.numeric.getBinForValue(10).diagnosticMaps, 1);
55 var dm = v.numeric.getBinForValue(10).diagnosticMaps[0]; 51 var dm = v.numeric.getBinForValue(10).diagnosticMaps[0];
56 assert.strictEqual(dm.size, 1); 52 assert.strictEqual(dm.size, 1);
57 assert.instanceOf(dm.get('bar'), tr.v.d.Generic); 53 assert.instanceOf(dm.get('bar'), tr.v.d.Generic);
58 assert.strictEqual(dm.get('bar').value, 'baz'); 54 assert.strictEqual(dm.get('bar').value, 'baz');
59 }); 55 });
60 56
61 test('computeSummaryValuesForNumericValue', function() { 57 test('computeSummaryValuesForNumericValue', function() {
62 var n = tr.v.NumericBuilder.createLinear( 58 var n = new tr.v.Histogram(tr.v.Unit.byName.unitlessNumber,
63 tr.v.Unit.byName.timeDurationInMs, tr.b.Range.fromExplicitRange(0, 100), 59 tr.v.HistogramBinBoundaries.createLinear(0, 100, 100));
64 100).build();
65 60
66 n.add(50); 61 n.add(50);
67 n.add(60); 62 n.add(60);
68 n.add(70); 63 n.add(70);
69 64
70 n.customizeSummaryOptions({ 65 n.customizeSummaryOptions({
71 count: true, 66 count: true,
72 min: true, 67 min: true,
73 max: true, 68 max: true,
74 sum: true, 69 sum: true,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 assert.strictEqual(rvm2.get('y'), b2); 213 assert.strictEqual(rvm2.get('y'), b2);
219 214
220 // Now a real c2 Value should be in a2's RelatedValueMap. 215 // Now a real c2 Value should be in a2's RelatedValueMap.
221 assert.strictEqual(rvm2.get('z'), c2); 216 assert.strictEqual(rvm2.get('z'), c2);
222 }); 217 });
223 218
224 test('sourceValuesWithSampleDiagnostic', function() { 219 test('sourceValuesWithSampleDiagnostic', function() {
225 var unit = tr.v.Unit.byName.unitlessNumber; 220 var unit = tr.v.Unit.byName.unitlessNumber;
226 var a = new tr.v.NumericValue('a', new tr.v.ScalarNumeric(unit, 1)); 221 var a = new tr.v.NumericValue('a', new tr.v.ScalarNumeric(unit, 1));
227 222
228 var numeric = tr.v.NumericBuilder.createLinear( 223 var numeric = new tr.v.Histogram(tr.v.Unit.byName.unitlessNumber);
229 tr.v.Unit.byName.timeDurationInMs,
230 tr.b.Range.fromExplicitRange(0, 1000), 10).build();
231 numeric.add(1, tr.v.d.DiagnosticMap.fromObject({ 224 numeric.add(1, tr.v.d.DiagnosticMap.fromObject({
232 rvs: new tr.v.d.RelatedValueSet([a])})); 225 rvs: new tr.v.d.RelatedValueSet([a])}));
233 var b = new tr.v.NumericValue('b', numeric); 226 var b = new tr.v.NumericValue('b', numeric);
234 227
235 var values = new tr.v.ValueSet([a, b]); 228 var values = new tr.v.ValueSet([a, b]);
236 assert.lengthOf(values.sourceValues, 1); 229 assert.lengthOf(values.sourceValues, 1);
237 assert.strictEqual(values.sourceValues[0], b); 230 assert.strictEqual(values.sourceValues[0], b);
238 }); 231 });
239 }); 232 });
240 </script> 233 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/value/ui/value_set_view_test.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698