Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <!-- | |
| 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 | |
| 5 found in the LICENSE file. | |
| 6 --> | |
| 7 | |
| 8 <link rel="import" href="/tracing/base/piecewise_linear_function.html"> | |
| 9 | |
| 10 <script> | |
| 11 'use strict'; | |
| 12 | |
| 13 tr.b.unittest.testSuite(function() { | |
| 14 test('PiecewiseLinearFunctionEmpty', function() { | |
| 15 var f = new tr.b.PiecewiseLinearFunction(); | |
| 16 assert.strictEqual(f.max, -Infinity); | |
| 17 assert.strictEqual(f.min, Infinity); | |
| 18 assert.strictEqual(f.average, 0); | |
| 19 assert.strictEqual(f.percentile(0.5), 0); | |
| 20 }); | |
|
petrcermak
2016/04/22 11:40:01
nit: add a blank line after this one
ulan
2016/04/22 12:32:26
Done.
| |
| 21 test('PiecewiseLinearFunction', function() { | |
| 22 var f = new tr.b.PiecewiseLinearFunction(); | |
| 23 f.push(0, 0.0, 10, 1.0); | |
| 24 f.push(10, 1.0, 20, 0.0); | |
| 25 f.push(20, 0.0, 30, 0.0); | |
| 26 assert.strictEqual(f.max, 1.0); | |
| 27 assert.strictEqual(f.min, 0.0); | |
| 28 assert.closeTo(f.average, 20 * 1 / 2.0 / 30, 1e-6); | |
| 29 assert.closeTo(f.percentile(1.0 / 3.0), 0.0, 1e-6); | |
| 30 assert.closeTo(f.percentile(2.0 / 3.0), 0.5, 1e-6); | |
| 31 }); | |
| 32 }); | |
| 33 </script> | |
| OLD | NEW |