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

Unified Diff: tracing/tracing/metrics/system_health/efficiency_metric.html

Issue 1730313007: Metric-ify SystemHealth metrics (Closed) Base URL: https://chromium.googlesource.com/external/github.com/catapult-project/catapult.git@master
Patch Set: rebase Created 4 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 side-by-side diff with in-line comments
Download patch
Index: tracing/tracing/metrics/system_health/efficiency_metric.html
diff --git a/tracing/tracing/metrics/system_health/efficiency_metric.html b/tracing/tracing/metrics/system_health/efficiency_metric.html
index 482efae281cd1bf5781347b35f827b03de57fbc1..51047144e529bbdd514a8fa69f74f201dd9b57df 100644
--- a/tracing/tracing/metrics/system_health/efficiency_metric.html
+++ b/tracing/tracing/metrics/system_health/efficiency_metric.html
@@ -6,46 +6,60 @@ found in the LICENSE file.
-->
<link rel="import" href="/tracing/base/statistics.html">
+<link rel="import" href="/tracing/metrics/metric_registry.html">
<link rel="import" href="/tracing/metrics/system_health/utils.html">
<link rel="import" href="/tracing/model/user_model/animation_expectation.html">
<link rel="import" href="/tracing/model/user_model/idle_expectation.html">
+<link rel="import" href="/tracing/value/numeric.html">
+<link rel="import" href="/tracing/value/value.html">
<script>
'use strict';
tr.exportTo('tr.metrics.sh', function() {
- function EfficiencyMetric() {
- }
+ var UNIT = tr.v.Unit.byName.normalizedPercentage_biggerIsBetter;
- EfficiencyMetric.forModel = function(model, opt_rangeOfInterest) {
- return tr.b.Statistics.weightedMean(
- tr.metrics.sh.filterExpectationsByRange(
- model.userModel.expectations, opt_rangeOfInterest),
- tr.metrics.sh.perceptualBlend,
- EfficiencyMetric.forExpectation);
- };
+ var DESCRIPTION = 'Normalized CPU budget consumption';
- EfficiencyMetric.forExpectation = function(ir) {
- if ((ir.totalCpuMs === undefined) ||
- (ir.totalCpuMs == 0))
- return undefined;
-
- var cpuFractionBudget = tr.b.Range.fromExplicitRange(0.5, 1.5);
-
- if (ir instanceof tr.model.um.IdleExpectation) {
- cpuFractionBudget = tr.b.Range.fromExplicitRange(0.1, 1);
- } else if (ir instanceof tr.model.um.AnimationExpectation) {
- cpuFractionBudget = tr.b.Range.fromExplicitRange(1, 2);
- }
-
- var cpuMsBudget = tr.b.Range.fromExplicitRange(
- ir.duration * cpuFractionBudget.min,
- ir.duration * cpuFractionBudget.max);
- var normalizedCpu = tr.b.normalize(
- ir.totalCpuMs, cpuMsBudget.min, cpuMsBudget.max);
- var normalizedCpuEfficiency = 1 - tr.b.clamp(normalizedCpu, 0, 1);
- return normalizedCpuEfficiency;
- };
+ function EfficiencyMetric(valueList, model) {
+ model.userModel.expectations.forEach(function(ue) {
+ var options = {};
+ options.description = DESCRIPTION;
+
+ var groupingKeys = {};
+ groupingKeys.userExpectation = ue.stableId;
+ groupingKeys.userExpectationStageTitle = ue.stageTitle;
+ groupingKeys.userExpectationInitiatorTitle = ue.initiatorTitle;
+
+ var score = undefined;
+
+ if ((ue.totalCpuMs === undefined) ||
+ (ue.totalCpuMs == 0))
+ return;
+
+ var cpuFractionBudget = tr.b.Range.fromExplicitRange(0.5, 1.5);
+
+ if (ue instanceof tr.model.um.IdleExpectation) {
+ cpuFractionBudget = tr.b.Range.fromExplicitRange(0.1, 1);
+ } else if (ue instanceof tr.model.um.AnimationExpectation) {
+ cpuFractionBudget = tr.b.Range.fromExplicitRange(1, 2);
+ }
+
+ var cpuMsBudget = tr.b.Range.fromExplicitRange(
+ ue.duration * cpuFractionBudget.min,
+ ue.duration * cpuFractionBudget.max);
+ var normalizedCpu = tr.b.normalize(
+ ue.totalCpuMs, cpuMsBudget.min, cpuMsBudget.max);
+ score = 1 - tr.b.clamp(normalizedCpu, 0, 1);
+
+ valueList.addValue(new tr.v.NumericValue(
+ model.canonicalUrlThatCreatedThisTrace, 'efficiency',
+ new tr.v.ScalarNumeric(UNIT, score),
+ options, groupingKeys));
+ });
+ }
+
+ tr.metrics.MetricRegistry.register(EfficiencyMetric);
return {
EfficiencyMetric: EfficiencyMetric

Powered by Google App Engine
This is Rietveld 408576698