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 }); | |
21 | |
22 test('PiecewiseLinearFunction', function() { | |
23 var f = new tr.b.PiecewiseLinearFunction(); | |
24 f.push(0, 0.0, 10, 1.0); | |
25 f.push(10, 1.0, 20, 0.0); | |
26 f.push(20, 0.0, 30, 0.0); | |
27 assert.strictEqual(f.max, 1.0); | |
28 assert.strictEqual(f.min, 0.0); | |
29 assert.closeTo(f.average, 20 * 1 / 2.0 / 30, 1e-6); | |
30 assert.closeTo(f.percentile(1.0 / 3.0), 0.0, 1e-6); | |
31 assert.closeTo(f.percentile(2.0 / 3.0), 0.5, 1e-6); | |
32 }); | |
33 }); | |
34 </script> | |
OLD | NEW |