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

Side by Side Diff: tracing/tracing/base/math/piecewise_linear_function_test.html

Issue 2771723003: [tracing] Move math utilities from base into their own subdirectory (attempt 2) (Closed)
Patch Set: rebase Created 3 years, 9 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
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/piecewise_linear_function.html"> 8 <link rel="import" href="/tracing/base/math/piecewise_linear_function.html">
9 9
10 <script> 10 <script>
11 'use strict'; 11 'use strict';
12 12
13 tr.b.unittest.testSuite(function() { 13 tr.b.unittest.testSuite(function() {
14 test('PiecewiseLinearFunctionEmpty', function() { 14 test('PiecewiseLinearFunctionEmpty', function() {
15 var f = new tr.b.PiecewiseLinearFunction(); 15 var f = new tr.b.math.PiecewiseLinearFunction();
16 assert.strictEqual(f.max, -Infinity); 16 assert.strictEqual(f.max, -Infinity);
17 assert.strictEqual(f.min, Infinity); 17 assert.strictEqual(f.min, Infinity);
18 assert.strictEqual(f.average, 0); 18 assert.strictEqual(f.average, 0);
19 assert.strictEqual(f.percentile(0.5), 0); 19 assert.strictEqual(f.percentile(0.5), 0);
20 }); 20 });
21 21
22 test('PiecewiseLinearFunction', function() { 22 test('PiecewiseLinearFunction', function() {
23 var f = new tr.b.PiecewiseLinearFunction(); 23 var f = new tr.b.math.PiecewiseLinearFunction();
24 f.push(0, 0.0, 10, 1.0); 24 f.push(0, 0.0, 10, 1.0);
25 f.push(10, 1.0, 20, 0.0); 25 f.push(10, 1.0, 20, 0.0);
26 f.push(20, 0.0, 30, 0.0); 26 f.push(20, 0.0, 30, 0.0);
27 assert.strictEqual(f.max, 1.0); 27 assert.strictEqual(f.max, 1.0);
28 assert.strictEqual(f.min, 0.0); 28 assert.strictEqual(f.min, 0.0);
29 assert.closeTo(f.average, 20 * 1 / 2.0 / 30, 1e-6); 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); 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); 31 assert.closeTo(f.percentile(2.0 / 3.0), 0.5, 1e-6);
32 }); 32 });
33 }); 33 });
34 </script> 34 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/base/math/piecewise_linear_function.html ('k') | tracing/tracing/base/math/quad.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698