| 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/range.html"> | 8 <link rel="import" href="/tracing/base/range.html"> |
| 9 <link rel="import" href="/tracing/metrics/metric_registry.html"> | 9 <link rel="import" href="/tracing/metrics/metric_registry.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/value.html"> | 11 <link rel="import" href="/tracing/value/value.html"> |
| 12 | 12 |
| 13 <script> | 13 <script> |
| 14 'use strict'; | 14 'use strict'; |
| 15 | 15 |
| 16 tr.exportTo('tr.metrics', function() { | 16 tr.exportTo('tr.metrics', function() { |
| 17 var SIZE_NUMERIC_BUILDER = tr.v.NumericBuilder.createLinear( | |
| 18 tr.v.Unit.byName.sizeInBytes_smallerIsBetter, | |
| 19 tr.b.Range.fromExplicitRange(0, 100), 10); | |
| 20 | |
| 21 function sampleMetric(values, model) { | 17 function sampleMetric(values, model) { |
| 22 var hist = SIZE_NUMERIC_BUILDER.build(); | 18 var hist = new tr.v.Histogram(tr.v.Unit.byName.sizeInBytes_smallerIsBetter); |
| 23 hist.add(9); | 19 hist.add(9); |
| 24 hist.add(91); | 20 hist.add(91); |
| 25 values.addValue(new tr.v.NumericValue('foo', hist)); | 21 values.addValue(new tr.v.NumericValue('foo', hist)); |
| 26 } | 22 } |
| 27 | 23 |
| 28 tr.metrics.MetricRegistry.register(sampleMetric); | 24 tr.metrics.MetricRegistry.register(sampleMetric); |
| 29 | 25 |
| 30 return { | 26 return { |
| 31 sampleMetric: sampleMetric | 27 sampleMetric: sampleMetric |
| 32 }; | 28 }; |
| 33 }); | 29 }); |
| 34 </script> | 30 </script> |
| OLD | NEW |