blob: 15e6c4a5f553486e8a1de22f8a02e6c2acd803f2 [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/ui/base/dom_helpers.html">
<link rel="import" href="/tracing/ui/base/overlay.html">
<link rel="import" href="/tracing/ui/base/table.html">
<link rel="import" href="/tracing/ui/units/time_duration_span.html">
<link rel="import" href="/perf_insights/results/results.html">
<link rel="import" href="/perf_insights/ui/reports/pi_report.html">
<link rel="import" href="/perf_insights/ui/generic_results_view.html">
<link rel="import" href="/perf_insights/mappers/reduce.html">
<link rel="import" href="/perf_insights/mappers/slice_cost.html">
<polymer-element name="pi-ui-wr-coverage-report"
extends="pi-ui-r-pi-report"
map-function-href="/perf_insights/mappers/weather_report_map_function.html"
map-function-name="weatherReportMapFunction">
<template>
<style>
:host {
display: flex;
flex-direction: column;
}
top-controls {
display: flex;
flex: 0 0 auto;
background-color: rgb(236, 236, 236);
border-bottom: 1px solid #8e8e8e;
padding: 4px;
}
#table {
flex: 1 1 auto;
}
</style>
<top-controls>
</top-controls>
<tr-ui-b-table id="table"></tr-ui-b-table>
</template>
<script>
'use strict';
Polymer({
created: function() {
this.mapResults_ = undefined;
},
get mapResults() {
return this.mapResults_;
},
set mapResults(mapResults) {
this.mapResults_ = mapResults;
this.updateContents_();
},
updateContents_: function() {
var table = this.$.table;
var results = this.mapResults_;
if (!results)
results = new tr.r.Results();
var columns = this.createColumns_();
table.tableColumns = columns;
table.sortColumnIndex = 2;
table.sortDescending = true;
var allCoverageInfo = [];
results.allValuesFromFailureFreeRuns.forEach(function(result) {
if (result.name != 'wr')
return;
// TODO(vmpstr): Why is there no irCoverage here?
if (!result.value.irCoverage) {
allCoverageInfo.push({
title: result.runInfo.displayName + ' (no coverage)',
coverage: {
associatedEventsCount: 'N/A',
unassociatedEventsCount: 'N/A',
coveredEventsCountRatio: 'N/A',
associatedEventsCpuTimeMs: 'N/A',
unassociatedEventsCpuTimeMs: 'N/A',
coveredEventsCpuTimeRatio: 'N/A'
}
});
return;
}
allCoverageInfo.push({
title: result.runInfo.displayName,
coverage: result.value.irCoverage
});
});
table.tableRows = allCoverageInfo;
table.rebuild();
},
createColumns_: function() {
function formatMs(value) {
var floatValue = parseFloat(value);
if (isNaN(floatValue))
return 'N/A';
var span = document.createElement('tr-ui-u-time-duration-span');
span.duration = floatValue;
return span;
}
function formatPercent(value) {
var floatValue = parseFloat(value);
if (isNaN(floatValue))
return 'N/A';
return tr.b.u.Units.normalizedPercentage.format(floatValue);
}
function formatCount(value) {
var intValue = parseInt(value);
if (isNaN(intValue))
return 'N/A';
return intValue.toLocaleString();
}
var columns = [
{
title: 'Title',
value: function(row) {
return row.title;
},
width: '400px',
cmp: function(a, b) {
return a.title.localeCompare(b.title);
}
},
{
title: 'Total event count',
value: function(row) {
return formatCount(row.coverage.associatedEventsCount +
row.coverage.unassociatedEventsCount);
},
textAlign: 'right',
cmp: function(a, b) {
var aTotal = a.coverage.associatedEventsCount +
a.coverage.unassociatedEventsCount;
var bTotal = b.coverage.associatedEventsCount +
b.coverage.unassociatedEventsCount;
return tr.b.compareNumericWithNaNs(aTotal, bTotal);
}
},
{
title: 'Associated event percentage',
value: function(row) {
return formatPercent(row.coverage.coveredEventsCountRatio);
},
textAlign: 'right',
cmp: function(a, b) {
return tr.b.compareNumericWithNaNs(
a.coverage.coveredEventsCountRatio,
b.coverage.coveredEventsCountRatio);
}
},
{
title: 'Total event CPU time',
value: function(row) {
return formatMs(row.coverage.associatedEventsCpuTimeMs +
row.coverage.unassociatedEventsCpuTimeMs);
},
textAlign: 'right',
cmp: function(a, b) {
var aTotal = a.coverage.associatedEventsCpuTimeMs +
a.coverage.unassociatedEventsCpuTimeMs;
var bTotal = b.coverage.associatedEventsCpuTimeMs +
b.coverage.unassociatedEventsCpuTimeMs;
return tr.b.compareNumericWithNaNs(aTotal, bTotal);
}
},
{
title: 'Associated time percentage',
value: function(row) {
return formatPercent(row.coverage.coveredEventsCpuTimeRatio);
},
textAlign: 'right',
cmp: function(a, b) {
return tr.b.compareNumericWithNaNs(
a.coverage.coveredEventsCpuTimeRatio,
b.coverage.coveredEventsCpuTimeRatio);
}
}
];
return columns;
}
});
</script>
</polymer-element>