OLD | NEW |
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/base/statistics.html"> | 8 <link rel="import" href="/tracing/base/statistics.html"> |
9 <link rel="import" href="/tracing/metrics/metric_registry.html"> | 9 <link rel="import" href="/tracing/metrics/metric_registry.html"> |
10 <link rel="import" href="/tracing/metrics/system_health/utils.html"> | 10 <link rel="import" href="/tracing/metrics/system_health/utils.html"> |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 var DESCRIPTION = 'Normalized CPU budget consumption'; | 22 var DESCRIPTION = 'Normalized CPU budget consumption'; |
23 | 23 |
24 function efficiencyMetric(values, model) { | 24 function efficiencyMetric(values, model) { |
25 var scores = []; | 25 var scores = []; |
26 | 26 |
27 model.userModel.expectations.forEach(function(ue) { | 27 model.userModel.expectations.forEach(function(ue) { |
28 var options = {}; | 28 var options = {}; |
29 options.description = DESCRIPTION; | 29 options.description = DESCRIPTION; |
30 | 30 |
31 var groupingKeys = {}; | |
32 groupingKeys.userExpectationStableId = ue.stableId; | |
33 groupingKeys.userExpectationStageTitle = ue.stageTitle; | |
34 groupingKeys.userExpectationInitiatorTitle = ue.initiatorTitle; | |
35 | |
36 var score = undefined; | 31 var score = undefined; |
37 | 32 |
38 if ((ue.totalCpuMs === undefined) || | 33 if ((ue.totalCpuMs === undefined) || |
39 (ue.totalCpuMs == 0)) | 34 (ue.totalCpuMs == 0)) |
40 return; | 35 return; |
41 | 36 |
42 var cpuFractionBudget = tr.b.Range.fromExplicitRange(0.5, 1.5); | 37 var cpuFractionBudget = tr.b.Range.fromExplicitRange(0.5, 1.5); |
43 | 38 |
44 if (ue instanceof tr.model.um.IdleExpectation) { | 39 if (ue instanceof tr.model.um.IdleExpectation) { |
45 cpuFractionBudget = tr.b.Range.fromExplicitRange(0.1, 1); | 40 cpuFractionBudget = tr.b.Range.fromExplicitRange(0.1, 1); |
46 } else if (ue instanceof tr.model.um.AnimationExpectation) { | 41 } else if (ue instanceof tr.model.um.AnimationExpectation) { |
47 cpuFractionBudget = tr.b.Range.fromExplicitRange(1, 2); | 42 cpuFractionBudget = tr.b.Range.fromExplicitRange(1, 2); |
48 } | 43 } |
49 | 44 |
50 var cpuMsBudget = tr.b.Range.fromExplicitRange( | 45 var cpuMsBudget = tr.b.Range.fromExplicitRange( |
51 ue.duration * cpuFractionBudget.min, | 46 ue.duration * cpuFractionBudget.min, |
52 ue.duration * cpuFractionBudget.max); | 47 ue.duration * cpuFractionBudget.max); |
53 var normalizedCpu = tr.b.normalize( | 48 var normalizedCpu = tr.b.normalize( |
54 ue.totalCpuMs, cpuMsBudget.min, cpuMsBudget.max); | 49 ue.totalCpuMs, cpuMsBudget.min, cpuMsBudget.max); |
55 score = 1 - tr.b.clamp(normalizedCpu, 0, 1); | 50 score = 1 - tr.b.clamp(normalizedCpu, 0, 1); |
56 | 51 |
57 scores.push(score); | 52 scores.push(score); |
58 | 53 |
59 values.addValue(new tr.v.NumericValue( | 54 values.addValue(new tr.v.NumericValue( |
60 model.canonicalUrl, 'efficiency', | 55 'efficiency', new tr.v.ScalarNumeric(UNIT, score), options)); |
61 new tr.v.ScalarNumeric(UNIT, score), | |
62 options, groupingKeys)); | |
63 }); | 56 }); |
64 | 57 |
65 // Manually reduce scores. | 58 // Manually reduce scores. |
66 // https://github.com/catapult-project/catapult/issues/2036 | 59 // https://github.com/catapult-project/catapult/issues/2036 |
67 | 60 |
68 var options = {}; | 61 var options = {}; |
69 options.description = DESCRIPTION; | 62 options.description = DESCRIPTION; |
70 var groupingKeys = {}; | |
71 var overallScore = tr.b.Statistics.weightedMean( | 63 var overallScore = tr.b.Statistics.weightedMean( |
72 scores, tr.metrics.sh.perceptualBlend); | 64 scores, tr.metrics.sh.perceptualBlend); |
73 if (overallScore === undefined) | 65 if (overallScore === undefined) |
74 return; | 66 return; |
75 | 67 |
76 values.addValue(new tr.v.NumericValue( | 68 values.addValue(new tr.v.NumericValue( |
77 model.canonicalUrl, 'efficiency', | 69 'efficiency', new tr.v.ScalarNumeric(UNIT, overallScore), options)); |
78 new tr.v.ScalarNumeric(UNIT, overallScore), | |
79 options, groupingKeys)); | |
80 } | 70 } |
81 | 71 |
82 tr.metrics.MetricRegistry.register(efficiencyMetric); | 72 tr.metrics.MetricRegistry.register(efficiencyMetric); |
83 | 73 |
84 return { | 74 return { |
85 efficiencyMetric: efficiencyMetric | 75 efficiencyMetric: efficiencyMetric |
86 }; | 76 }; |
87 }); | 77 }); |
88 </script> | 78 </script> |
OLD | NEW |