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

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

Issue 2283213002: Rename Histogram.add() to addSample(). (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 = new tr.v.Histogram(tr.v.Unit.byName.unitlessNumber); 20 var n = new tr.v.Histogram(tr.v.Unit.byName.unitlessNumber);
21 n.add(10); 21 n.addSample(10);
22 n.customizeSummaryOptions({ 22 n.customizeSummaryOptions({
23 count: true, 23 count: true,
24 min: false, 24 min: false,
25 max: false, 25 max: false,
26 sum: true, 26 sum: true,
27 avg: false, 27 avg: false,
28 std: false 28 std: false
29 }); 29 });
30 30
31 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)]);
32 var values2 = new tr.v.ValueSet(); 32 var values2 = new tr.v.ValueSet();
33 values2.addValuesFromDicts(values.valueDicts); 33 values2.addValuesFromDicts(values.valueDicts);
34 // foo, foo_count, foo_sum 34 // foo, foo_count, foo_sum
35 assert.lengthOf(values2.getValuesWithName('foo'), 3); 35 assert.lengthOf(values2.getValuesWithName('foo'), 3);
36 assert.lengthOf(values2.getValuesNamed('foo'), 1); 36 assert.lengthOf(values2.getValuesNamed('foo'), 1);
37 }); 37 });
38 38
39 test('addValueFromDictsWithSampleDiagnostic', function() { 39 test('addValueFromDictsWithSampleDiagnostic', function() {
40 var n = new tr.v.Histogram(tr.v.Unit.byName.count); 40 var n = new tr.v.Histogram(tr.v.Unit.byName.count);
41 n.add(10, tr.v.d.DiagnosticMap.fromObject({ 41 n.addSample(10, {bar: new tr.v.d.Generic('baz')});
42 bar: new tr.v.d.Generic('baz')
43 }));
44 42
45 var values = new tr.v.ValueSet([new tr.v.NumericValue('foo', n)]); 43 var values = new tr.v.ValueSet([new tr.v.NumericValue('foo', n)]);
46 var values2 = new tr.v.ValueSet(); 44 var values2 = new tr.v.ValueSet();
47 values2.addValuesFromDicts(values.valueDicts); 45 values2.addValuesFromDicts(values.valueDicts);
48 assert.lengthOf(values2.getValuesNamed('foo'), 1); 46 assert.lengthOf(values2.getValuesNamed('foo'), 1);
49 var v = values2.getValuesNamed('foo')[0]; 47 var v = values2.getValuesNamed('foo')[0];
50 assert.lengthOf(v.numeric.getBinForValue(10).diagnosticMaps, 1); 48 assert.lengthOf(v.numeric.getBinForValue(10).diagnosticMaps, 1);
51 var dm = v.numeric.getBinForValue(10).diagnosticMaps[0]; 49 var dm = v.numeric.getBinForValue(10).diagnosticMaps[0];
52 assert.strictEqual(dm.size, 1); 50 assert.strictEqual(dm.size, 1);
53 assert.instanceOf(dm.get('bar'), tr.v.d.Generic); 51 assert.instanceOf(dm.get('bar'), tr.v.d.Generic);
54 assert.strictEqual(dm.get('bar').value, 'baz'); 52 assert.strictEqual(dm.get('bar').value, 'baz');
55 }); 53 });
56 54
57 test('computeSummaryValuesForNumericValue', function() { 55 test('computeSummaryValuesForNumericValue', function() {
58 var n = new tr.v.Histogram(tr.v.Unit.byName.unitlessNumber, 56 var n = new tr.v.Histogram(tr.v.Unit.byName.unitlessNumber,
59 tr.v.HistogramBinBoundaries.createLinear(0, 100, 100)); 57 tr.v.HistogramBinBoundaries.createLinear(0, 100, 100));
60 58
61 n.add(50); 59 n.addSample(50);
62 n.add(60); 60 n.addSample(60);
63 n.add(70); 61 n.addSample(70);
64 62
65 n.customizeSummaryOptions({ 63 n.customizeSummaryOptions({
66 count: true, 64 count: true,
67 min: true, 65 min: true,
68 max: true, 66 max: true,
69 sum: true, 67 sum: true,
70 avg: true, 68 avg: true,
71 std: true, 69 std: true,
72 percentile: [0.5, 1] 70 percentile: [0.5, 1]
73 }); 71 });
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // b2 should still be in a2's RelatedValueMap. 210 // b2 should still be in a2's RelatedValueMap.
213 assert.strictEqual(rvm2.get('y'), b2); 211 assert.strictEqual(rvm2.get('y'), b2);
214 212
215 // Now a real c2 Value should be in a2's RelatedValueMap. 213 // Now a real c2 Value should be in a2's RelatedValueMap.
216 assert.strictEqual(rvm2.get('z'), c2); 214 assert.strictEqual(rvm2.get('z'), c2);
217 }); 215 });
218 216
219 test('sourceValuesWithSampleDiagnostic', function() { 217 test('sourceValuesWithSampleDiagnostic', function() {
220 var unit = tr.v.Unit.byName.unitlessNumber; 218 var unit = tr.v.Unit.byName.unitlessNumber;
221 var aHist = new tr.v.Histogram(unit); 219 var aHist = new tr.v.Histogram(unit);
222 aHist.add(1); 220 aHist.addSample(1);
223 var a = new tr.v.NumericValue('a', aHist); 221 var a = new tr.v.NumericValue('a', aHist);
224 222
225 var numeric = new tr.v.Histogram(tr.v.Unit.byName.unitlessNumber); 223 var numeric = new tr.v.Histogram(tr.v.Unit.byName.unitlessNumber);
226 numeric.add(1, tr.v.d.DiagnosticMap.fromObject({ 224 numeric.addSample(1, {rvs: new tr.v.d.RelatedValueSet([a])});
227 rvs: new tr.v.d.RelatedValueSet([a])}));
228 var b = new tr.v.NumericValue('b', numeric); 225 var b = new tr.v.NumericValue('b', numeric);
229 226
230 var values = new tr.v.ValueSet([a, b]); 227 var values = new tr.v.ValueSet([a, b]);
231 assert.lengthOf(values.sourceValues, 1); 228 assert.lengthOf(values.sourceValues, 1);
232 assert.strictEqual(values.sourceValues[0], b); 229 assert.strictEqual(values.sourceValues[0], b);
233 }); 230 });
234 }); 231 });
235 </script> 232 </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