blob: 621df989f70cba559d4911ccef2e4cc8b50aeee7 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/tracing/metrics/value_list.html">
<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html">
<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html">
<link rel="import" href="/tracing/value/ui/scalar_span.html">
<link rel="import" href="/tracing/value/unit.html">
<polymer-element name="tr-ui-a-single-user-expectation-sub-view"
extends="tr-ui-a-sub-view">
<script>
'use strict';
Polymer({
created: function() {
this.currentSelection_ = undefined;
this.realView_ = undefined;
},
get selection() {
return this.currentSelection_;
},
set selection(selection) {
this.textContent = '';
this.realView_ = document.createElement('tr-ui-a-single-event-sub-view');
this.realView_.addEventListener('customize-rows',
this.onCustomizeRows_.bind(this));
this.appendChild(this.realView_);
this.currentSelection_ = selection;
this.realView_.setSelectionWithoutErrorChecks(selection);
},
get relatedEventsToHighlight() {
if (!this.currentSelection_)
return undefined;
return this.currentSelection_[0].associatedEvents;
},
onCustomizeRows_: function(event) {
var ue = this.selection[0];
var valueList = new tr.metrics.ValueList();
function runMetric(metricInfo) {
try {
metricInfo.constructor(valueList, ue.parentModel);
} catch (failure) {
console.error(metricInfo, failure);
}
}
tr.metrics.MetricRegistry.getAllRegisteredTypeInfos().forEach(runMetric);
// Metrics may have been computed more than once, so avoid displaying them
// more than once by collecting them in a dictionary.
// https://github.com/catapult-project/catapult/issues/2154
var metricValues = {};
valueList.valueDicts.forEach(function(value) {
if (value.grouping_keys.userExpectationStableId !== ue.stableId)
return;
if ((value.type !== 'numeric') ||
(value.numeric.type !== 'scalar'))
return;
metricValues[value.grouping_keys.name] = value.numeric;
});
for (var name in metricValues) {
event.rows.push({
name: name,
value: tr.v.ui.createScalarSpan(metricValues[name].value, {
unit: tr.v.Unit.fromJSON(metricValues[name].unit)
})
});
}
if (ue.rawCpuMs) {
event.rows.push({
name: 'Total CPU',
value: tr.v.ui.createScalarSpan(ue.totalCpuMs, {
unit: tr.v.Unit.byName.timeDurationInMs
})
});
}
}
});
</script>
</polymer-element>