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

Side by Side Diff: tracing/tracing/metrics/system_health/hazard_metric.html

Issue 2293533002: Refactor NumericBuilder to HistogramBinBoundaries. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: rebase Created 4 years, 3 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 7
8 <link rel="import" href="/tracing/metrics/metric_registry.html"> 8 <link rel="import" href="/tracing/metrics/metric_registry.html">
9 <link rel="import" href="/tracing/metrics/system_health/long_tasks_metric.html"> 9 <link rel="import" href="/tracing/metrics/system_health/long_tasks_metric.html">
10 <link rel="import" href="/tracing/value/numeric.html"> 10 <link rel="import" href="/tracing/value/numeric.html">
11 <link rel="import" href="/tracing/value/value.html"> 11 <link rel="import" href="/tracing/value/value.html">
12 12
13 <script> 13 <script>
14 'use strict'; 14 'use strict';
15 15
16 tr.exportTo('tr.metrics.sh', function() { 16 tr.exportTo('tr.metrics.sh', function() {
17 var NUMERIC_BUILDER = tr.v.NumericBuilder.createLinear(
18 tr.v.Unit.byName.normalizedPercentage_smallerIsBetter,
19 tr.b.Range.fromExplicitRange(0, 1), 20);
20
21 // The following math is easier if the units are seconds rather than ms, 17 // The following math is easier if the units are seconds rather than ms,
22 // so durations will be converted from ms to s. 18 // so durations will be converted from ms to s.
23 var MS_PER_S = 1000; 19 var MS_PER_S = 1000;
24 20
25 // https://www.desmos.com/calculator/ysabhcc42g 21 // https://www.desmos.com/calculator/ysabhcc42g
26 var RESPONSE_RISK = 22 var RESPONSE_RISK =
27 tr.b.Statistics.LogNormalDistribution.fromMedianAndDiminishingReturns( 23 tr.b.Statistics.LogNormalDistribution.fromMedianAndDiminishingReturns(
28 100 / MS_PER_S, 50 / MS_PER_S); 24 100 / MS_PER_S, 50 / MS_PER_S);
29 25
30 /** 26 /**
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 * This EXPERIMENTAL metric computes a scalar normalized score that 117 * This EXPERIMENTAL metric computes a scalar normalized score that
122 * represents the risk that a speculative input's responsiveness would have 118 * represents the risk that a speculative input's responsiveness would have
123 * been impacted by long tasks. 119 * been impacted by long tasks.
124 * This metric requires only the 'toplevel' tracing category. 120 * This metric requires only the 'toplevel' tracing category.
125 */ 121 */
126 function hazardMetric(values, model) { 122 function hazardMetric(values, model) {
127 var overallHazard = computeHazardForLongTasks(model); 123 var overallHazard = computeHazardForLongTasks(model);
128 if (overallHazard === undefined) 124 if (overallHazard === undefined)
129 overallHazard = 0; 125 overallHazard = 0;
130 126
131 var hist = NUMERIC_BUILDER.build(); 127 var hist = new tr.v.Histogram(
128 tr.v.Unit.byName.normalizedPercentage_smallerIsBetter);
132 hist.add(overallHazard); 129 hist.add(overallHazard);
133 values.addValue(new tr.v.NumericValue('hazard', hist)); 130 values.addValue(new tr.v.NumericValue('hazard', hist));
134 } 131 }
135 132
136 tr.metrics.MetricRegistry.register(hazardMetric); 133 tr.metrics.MetricRegistry.register(hazardMetric);
137 134
138 return { 135 return {
139 hazardMetric: hazardMetric, 136 hazardMetric: hazardMetric,
140 computeHazardForLongTasksInRangeOnThread: 137 computeHazardForLongTasksInRangeOnThread:
141 computeHazardForLongTasksInRangeOnThread, 138 computeHazardForLongTasksInRangeOnThread,
142 computeHazardForLongTasks: computeHazardForLongTasks, 139 computeHazardForLongTasks: computeHazardForLongTasks,
143 computeResponsivenessRisk: computeResponsivenessRisk 140 computeResponsivenessRisk: computeResponsivenessRisk
144 }; 141 };
145 }); 142 });
146 </script> 143 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698