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

Side by Side Diff: tracing/tracing/base/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
« no previous file with comments | « tracing/tracing/base/piecewise_linear_function.html ('k') | tracing/tracing/base/quad.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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>
OLDNEW
« no previous file with comments | « tracing/tracing/base/piecewise_linear_function.html ('k') | tracing/tracing/base/quad.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698