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

Unified Diff: tracing/tracing/metrics/ui/system_health/system_health_side_panel.html

Issue 1772833002: Remove SystemHealthMetric (fka RAILScore) (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: fix pi test 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/ui/system_health/system_health_side_panel.html
diff --git a/tracing/tracing/metrics/ui/system_health/system_health_side_panel.html b/tracing/tracing/metrics/ui/system_health/system_health_side_panel.html
deleted file mode 100644
index 26b4d395ab92c4951ea49730042752b76358f9a7..0000000000000000000000000000000000000000
--- a/tracing/tracing/metrics/ui/system_health/system_health_side_panel.html
+++ /dev/null
@@ -1,341 +0,0 @@
-<!DOCTYPE html>
-<!--
-Copyright 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/importer/user_model_builder.html">
-<link rel="import" href="/tracing/metrics/system_health/system_health_metric.html">
-<link rel="import" href="/tracing/metrics/ui/system_health/system_health_span.html">
-<link rel="import" href="/tracing/model/ir_coverage.html">
-<link rel="import" href="/tracing/ui/analysis/analysis_link.html">
-<link rel="import" href="/tracing/ui/base/color_legend.html">
-<link rel="import" href="/tracing/ui/base/table.html">
-<link rel="import" href="/tracing/ui/base/utils.html">
-<link rel="import" href="/tracing/ui/side_panel/side_panel.html">
-<link rel="import" href="/tracing/value/ui/time_duration_span.html">
-
-<polymer-element name='tr-metrics-ui-sh-system-health-side-panel'
- extends='tr-ui-side-panel'>
- <template>
- <style>
- :host {
- display: flex;
- flex-direction: column;
- width: 450px;
- overflow-x: auto;
- }
-
- #score {
- background-color: rgb(236, 236, 236)
- flex: 0 0 auto;
- }
-
- #content {
- min-width: 0;
- flex-direction: column;
- display: flex;
- flex: 1 1 auto;
- }
-
- #coverage {
- font-size: 10px;
- margin-top: 1em;
- margin-bottom: 1em;
- }
- </style>
-
- <tr-ui-b-table id="table"></tr-ui-b-table>
-
- <div id="coverage">
- <b>Coverage:</b><br>
- <tr-ui-a-analysis-link id="associated-events"></tr-ui-a-analysis-link><br>
- <tr-ui-a-analysis-link id="unassociated-events"></tr-ui-a-analysis-link>
- </div>
-
- <button id="test">Create Test</button>
- </template>
-</polymer-element>
-
-<script>
-'use strict';
-(function() {
- function setCoverageLink(
- link, labelString, events, eventRatio, cpuMs, cpuRatio) {
- link.setSelectionAndContent(events);
-
- labelString += ' ' + events.length + ' events';
- labelString += ' (' + parseInt(100 * eventRatio) + '%)';
- if (cpuRatio !== undefined)
- labelString += ', ';
- link.appendChild(document.createTextNode(labelString));
-
- if (cpuRatio === undefined)
- return;
-
- var cpuMsSpan = document.createElement('tr-v-ui-time-duration-span');
- // There will be some text after the cpuMsSpan, that should be on the same
- // line if it fits. This "span" has display: block for its sparkline... so I
- // guess I'll set it inline here?
- cpuMsSpan.style.display = 'inline';
- cpuMsSpan.duration = cpuMs;
- cpuMsSpan.contentTextDecoration = 'underline';
- link.appendChild(cpuMsSpan);
-
- var cpuString = ' (' + parseInt(100 * cpuRatio) + '%)';
- link.appendChild(document.createTextNode(cpuString));
- }
-
- var FOOTER_ROW_STAGE_TITLE = 'Overall';
-
- var ResponsivenessMetric = tr.metrics.sh.ResponsivenessMetric;
- var SystemHealthMetric = tr.metrics.sh.SystemHealthMetric;
- var EfficiencyMetric = tr.metrics.sh.EfficiencyMetric;
-
- Polymer('tr-metrics-ui-sh-system-health-side-panel', {
- ready: function() {
- this.rangeOfInterest_ = new tr.b.Range();
- this.model_ = undefined;
- this.selection_ = new tr.model.EventSet();
- this.$.test.addEventListener('click', this.createTest_.bind(this));
- },
-
- createTest_: function() {
- var overlay = new tr.ui.b.Overlay();
- overlay.title = 'UserModelBuilder test';
- var textarea = document.createElement('textarea');
- textarea.textContent = tr.e.rail.createIRFinderTestCaseStringFromModel(
- this.model_);
- textarea.rows = textarea.textContent.split('\n').length;
- textarea.cols = 80;
- overlay.appendChild(textarea);
- overlay.visible = true;
- textarea.select();
- textarea.focus();
- },
-
- get textLabel() {
- return 'System Health';
- },
-
- supportsModel: function(m) {
- if (m === undefined) {
- return {
- supported: false,
- reason: 'Unknown tracing model'
- };
- }
- if (SystemHealthMetric.forModel(m) === undefined) {
- return {
- supported: false,
- reason: 'No expectations found on the model'
- };
- }
- return {
- supported: true
- };
- },
-
- get model() {
- return this.model_;
- },
-
- set model(model) {
- this.model_ = model;
- this.updateCoverage_();
- this.updateTable_();
- },
-
- get effectiveRangeOfInterest() {
- if (!this.rangeOfInterest_ || this.rangeOfInterest_.isEmpty) {
- if (this.model)
- return this.model.bounds;
- else
- return new tr.b.Range();
- }
-
- return this.rangeOfInterest_;
- },
-
- set rangeOfInterest(rangeOfInterest) {
- this.rangeOfInterest_ = rangeOfInterest;
- // TODO(benjhayden): Make updateCoverage_ reflect rangeOfInterest.
- // https://github.com/catapult-project/catapult/issues/1753
- this.updateTable_();
- },
-
- updateCoverage_: function() {
- if (!this.model)
- return;
-
- var coverage = tr.model.getIRCoverageFromModel(this.model);
-
- if (!coverage)
- return;
-
- var associatedEvents =
- tr.model.getAssociatedEvents(this.model.userModel.expectations);
- var unassociatedEvents = tr.model.getUnassociatedEvents(
- this.model, associatedEvents);
-
- // coveredEventsCountRatio is guaranteed to be defined because
- // getIRCoverageFromModel would have returned undefined if there were zero
- // events.
- // However, totalCpuMs may be zero for traces from windows, so
- // coveredEventsCpuTimeRatio may be undefined.
- var unassociatedCpuRatio = undefined;
- if (coverage.coveredEventsCpuTimeRatio !== undefined)
- unassociatedCpuRatio = 1.0 - coverage.coveredEventsCpuTimeRatio;
-
- setCoverageLink(this.shadowRoot.querySelector('#associated-events'),
- 'Associated',
- associatedEvents,
- coverage.coveredEventsCountRatio,
- coverage.associatedEventsCpuTimeMs,
- coverage.coveredEventsCpuTimeRatio);
- setCoverageLink(this.shadowRoot.querySelector('#unassociated-events'),
- 'Unassociated',
- unassociatedEvents,
- 1.0 - coverage.coveredEventsCountRatio,
- coverage.unassociatedEventsCpuTimeMs,
- unassociatedCpuRatio);
- },
-
- updateTable_: function() {
- if (!this.model)
- return;
-
- var columns = [
- {
- title: 'Type',
- width: '150px',
- value: function(ir) {
- if (ir.stageTitle === FOOTER_ROW_STAGE_TITLE)
- return FOOTER_ROW_STAGE_TITLE;
-
- var events = new tr.model.EventSet([ir]);
- events.addEventSet(ir.associatedEvents);
-
- var linkEl = document.createElement('tr-ui-a-analysis-link');
- linkEl.setSelectionAndContent(events, ir.stageTitle);
-
- var el = document.createElement('tr-ui-b-color-legend');
- el.setLabelAndColorId(linkEl, ir.colorId);
- el.compoundEventSelectionState =
- ir.computeCompoundEvenSelectionState(this.selection_);
- return el;
- }.bind(this),
- cmp: function(a, b) {
- return a.stageTitle.localeCompare(b.stageTitle);
- }
- },
- {
- title: 'Efficiency',
- width: '33%',
- value: function(ir) {
- var efficiency;
- if (ir.stageTitle === FOOTER_ROW_STAGE_TITLE) {
- efficiency = EfficiencyMetric.forModel(
- this.model, this.effectiveRangeOfInterest);
- } else {
- efficiency = EfficiencyMetric.forExpectation(ir);
- }
-
- if (efficiency === undefined)
- return '';
- return tr.ui.b.toThreeDigitLocaleString(efficiency);
- }.bind(this),
- textAlign: 'right',
- cmp: function(a, b) {
- return EfficiencyMetric.forExpectation(a) -
- EfficiencyMetric.forExpectation(b);
- }
- },
- {
- title: 'Responsiveness',
- width: '33%',
- value: function(ir) {
- var responsiveness;
- if (ir.stageTitle === FOOTER_ROW_STAGE_TITLE) {
- responsiveness = ResponsivenessMetric.forModel(
- this.model, this.effectiveRangeOfInterest);
- } else {
- responsiveness = ResponsivenessMetric.forExpectation(ir);
- }
-
- if (responsiveness === undefined)
- return '';
- return tr.ui.b.toThreeDigitLocaleString(responsiveness);
- }.bind(this),
- textAlign: 'right',
- cmp: function(a, b) {
- return ResponsivenessMetric.forExpectation(a) -
- ResponsivenessMetric.forExpectation(b);
- }
- },
- {
- title: 'Score',
- width: '33%',
- value: function(ir) {
- var sh;
- if (ir.stageTitle === FOOTER_ROW_STAGE_TITLE) {
- sh = SystemHealthMetric.forModel(
- this.model, this.effectiveRangeOfInterest);
- } else {
- sh = SystemHealthMetric.forExpectation(ir);
- }
-
- if (sh === undefined)
- return '';
-
- var span = document.createElement('span');
- span.style.fontWeight = 'bold';
- span.textContent = tr.ui.b.toThreeDigitLocaleString(sh);
- return span;
- }.bind(this),
- textAlign: 'right',
- cmp: function(a, b) {
- return SystemHealthMetric.forExpectation(a) -
- SystemHealthMetric.forExpectation(b);
- }
- }
- ];
-
- this.$.table.tableColumns = columns;
-
- var rows = [];
- this.model.userModel.expectations.forEach(function(ir) {
- if (!this.effectiveRangeOfInterest.intersectsExplicitRangeExclusive(
- ir.start, ir.end))
- return;
-
- rows.push(ir);
- }, this);
-
- this.$.table.tableRows = rows;
- this.$.table.footerRows = [{stageTitle: FOOTER_ROW_STAGE_TITLE}];
- this.$.table.rebuild();
- },
-
- onTableSelectionChanged_: function() {
- var selectedIR = this.$.table.selectedTableRow;
-
- var event = new tr.c.RequestSelectionChangeEvent();
- event.selection = new tr.c.Selection([selectedIR]);
- this.dispatchEvent(event);
- },
-
- set selection(selection) {
- if (selection === undefined)
- selection = new tr.model.EventSet();
-
- if (this.selection_.equals(selection))
- return;
-
- this.selection_ = selection;
- this.updateTable_();
- }
- });
-})();
-</script>

Powered by Google App Engine
This is Rietveld 408576698