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

Side by Side Diff: tracing/tracing/metrics/system_health/utils.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 (c) 2015 The Chromium Authors. All rights reserved. 3 Copyright (c) 2015 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 <link rel="import" href="/tracing/model/user_model/user_expectation.html"> 7 <link rel="import" href="/tracing/model/user_model/user_expectation.html">
8 8
9 <script> 9 <script>
10 'use strict'; 10 'use strict';
11 11
12 tr.exportTo('tr.metrics.sh', function() { 12 tr.exportTo('tr.metrics.sh', function() {
13 // Returns a weight for this score. 13 // Returns a weight for this score.
14 // score should be a number between 0 and 1 inclusive. 14 // score should be a number between 0 and 1 inclusive.
15 // This function is expected to be passed to tr.b.Statistics.weightedMean as 15 // This function is expected to be passed to tr.b.math.Statistics.weightedMean
16 // its weightCallback. 16 // as its weightCallback.
17 function perceptualBlend(ir, index, score) { 17 function perceptualBlend(ir, index, score) {
18 // Lower scores are exponentially more important than higher scores 18 // Lower scores are exponentially more important than higher scores
19 // due to the Peak-end rule. 19 // due to the Peak-end rule.
20 // Other than that general rule, there is no specific reasoning behind this 20 // Other than that general rule, there is no specific reasoning behind this
21 // specific formula -- it is fairly arbitrary. 21 // specific formula -- it is fairly arbitrary.
22 return Math.exp(1 - score); 22 return Math.exp(1 - score);
23 } 23 }
24 24
25 function filterExpectationsByRange(irs, opt_range) { 25 function filterExpectationsByRange(irs, opt_range) {
26 var filteredExpectations = []; 26 var filteredExpectations = [];
27 irs.forEach(function(ir) { 27 irs.forEach(function(ir) {
28 if (!(ir instanceof tr.model.um.UserExpectation)) 28 if (!(ir instanceof tr.model.um.UserExpectation))
29 return; 29 return;
30 30
31 if (!opt_range || 31 if (!opt_range ||
32 opt_range.intersectsExplicitRangeInclusive(ir.start, ir.end)) 32 opt_range.intersectsExplicitRangeInclusive(ir.start, ir.end))
33 filteredExpectations.push(ir); 33 filteredExpectations.push(ir);
34 }); 34 });
35 return filteredExpectations; 35 return filteredExpectations;
36 } 36 }
37 37
38 return { 38 return {
39 perceptualBlend, 39 perceptualBlend,
40 filterExpectationsByRange, 40 filterExpectationsByRange,
41 }; 41 };
42 }); 42 });
43 </script> 43 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/metrics/system_health/responsiveness_metric.html ('k') | tracing/tracing/metrics/v8/execution_metric.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698