2019-01-04 12:18:43 +00:00
|
|
|
<!DOCTYPE html>
|
2016-05-06 13:23:51 +00:00
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
Copyright 2016 the V8 project authors. All rights reserved. Use of this source
|
|
|
|
code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
-->
|
|
|
|
|
|
|
|
<head>
|
2019-01-04 12:18:43 +00:00
|
|
|
<meta charset="utf-8">
|
2021-03-02 13:56:46 +00:00
|
|
|
<title>V8 Runtime Call Stats Komparator</title>
|
|
|
|
<link rel="stylesheet" type="text/css" href="system-analyzer/index.css">
|
2016-05-06 13:23:51 +00:00
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
font-family: arial;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
.panel {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.loaded .panel {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
|
|
|
.panel.alwaysVisible {
|
|
|
|
display: inherit !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.error #inputs {
|
|
|
|
background-color: var(--error-color);
|
|
|
|
}
|
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
table {
|
|
|
|
display: table;
|
|
|
|
border-spacing: 0px;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
tr {
|
|
|
|
border-spacing: 0px;
|
|
|
|
padding: 10px;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
td,
|
|
|
|
th {
|
|
|
|
padding: 3px 10px 3px 5px;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.inline {
|
|
|
|
display: inline-block;
|
2021-03-02 13:56:46 +00:00
|
|
|
vertical-align: middle;
|
|
|
|
margin-right: 10px;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.hidden {
|
|
|
|
display: none;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.view {
|
|
|
|
display: table;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
.panel-group {
|
|
|
|
display: grid;
|
|
|
|
align-content: center;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
|
|
|
|
grid-auto-flow: row dense;
|
|
|
|
grid-gap: 10px;
|
|
|
|
margin-top: 10px;
|
|
|
|
}
|
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.column {
|
|
|
|
display: table-cell;
|
|
|
|
border-right: 1px black dotted;
|
|
|
|
min-width: 200px;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.column .header {
|
|
|
|
padding: 0 10px 0 10px
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
#column {
|
|
|
|
display: none;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.list {
|
|
|
|
width: 100%;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
select {
|
|
|
|
width: 100%
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.list tbody {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.list tr:nth-child(even) {
|
2021-03-02 13:56:46 +00:00
|
|
|
background-color: rgba(0.5, 0.5, 0.5, 0.1);
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.list tr.child {
|
|
|
|
display: none;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.list tr.child.visible {
|
|
|
|
display: table-row;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.list .child .name {
|
|
|
|
padding-left: 20px;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.list .parent td {
|
|
|
|
border-top: 1px solid #AAA;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.list .total {
|
|
|
|
font-weight: bold
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
.list tr.parent.selected,
|
|
|
|
.list tr:nth-child(even).selected,
|
2016-05-06 13:23:51 +00:00
|
|
|
tr.selected {
|
2021-03-02 13:56:46 +00:00
|
|
|
background-color: rgba(0.5, 0.5, 0.5, 0.1);
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
.codeSearch {
|
|
|
|
display: block-inline;
|
|
|
|
float: right;
|
|
|
|
border-radius: 5px;
|
2021-03-17 10:07:14 +00:00
|
|
|
background-color: #333;
|
2016-06-06 13:07:20 +00:00
|
|
|
width: 1em;
|
|
|
|
text-align: center;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.list .position {
|
|
|
|
text-align: right;
|
|
|
|
display: none;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.list div.toggle {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
#column_0 .position {
|
|
|
|
display: table-cell;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
#column_0 .name {
|
|
|
|
display: table-cell;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.list .name {
|
|
|
|
display: none;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.value {
|
|
|
|
text-align: right;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.selectedVersion {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
#baseline {
|
|
|
|
width: auto;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.pageDetailTable tbody {
|
|
|
|
cursor: pointer
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-11 12:32:27 +00:00
|
|
|
.pageDetailTable tfoot td {
|
|
|
|
border-top: 1px grey solid;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
#popover {
|
|
|
|
position: absolute;
|
|
|
|
transform: translateY(-50%) translateX(40px);
|
|
|
|
box-shadow: -2px 10px 44px -10px #000;
|
|
|
|
border-radius: 5px;
|
|
|
|
z-index: 1;
|
2021-03-02 13:56:46 +00:00
|
|
|
background-color: var(--surface-color);
|
2016-05-06 13:23:51 +00:00
|
|
|
display: none;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
#popover table {
|
|
|
|
position: relative;
|
|
|
|
z-index: 1;
|
|
|
|
text-align: right;
|
|
|
|
margin: 10px;
|
|
|
|
}
|
2021-03-17 10:07:14 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
#popover td {
|
|
|
|
padding: 3px 0px 3px 5px;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
.popoverArrow {
|
2021-03-02 13:56:46 +00:00
|
|
|
background-color: var(--surface-color);
|
2016-05-06 13:23:51 +00:00
|
|
|
position: absolute;
|
|
|
|
width: 30px;
|
|
|
|
height: 30px;
|
|
|
|
transform: translateY(-50%)rotate(45deg);
|
|
|
|
top: 50%;
|
|
|
|
left: -10px;
|
|
|
|
z-index: 0;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
#popover .name {
|
|
|
|
padding: 5px;
|
|
|
|
font-weight: bold;
|
|
|
|
text-align: center;
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
#popover table .compare {
|
|
|
|
display: none
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
#popover table.compare .compare {
|
|
|
|
display: table-cell;
|
|
|
|
}
|
2016-05-11 12:32:27 +00:00
|
|
|
|
|
|
|
#popover .compare .time,
|
|
|
|
#popover .compare .version {
|
|
|
|
padding-left: 10px;
|
|
|
|
}
|
2021-03-17 10:07:14 +00:00
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
.diff .hideDiff {
|
|
|
|
display: none;
|
|
|
|
}
|
2021-03-17 10:07:14 +00:00
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
.noDiff .hideNoDiff {
|
|
|
|
display: none;
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
</style>
|
2019-01-04 12:18:43 +00:00
|
|
|
<script src="https://www.gstatic.com/charts/loader.js"></script>
|
|
|
|
<script>
|
2016-05-06 13:23:51 +00:00
|
|
|
"use strict"
|
2021-03-17 10:07:14 +00:00
|
|
|
google.charts.load('current', {
|
|
|
|
packages: ['corechart']
|
|
|
|
});
|
2016-05-06 13:23:51 +00:00
|
|
|
|
|
|
|
// Did anybody say monkeypatching?
|
|
|
|
if (!NodeList.prototype.forEach) {
|
2021-03-17 10:07:14 +00:00
|
|
|
NodeList.prototype.forEach = function (func) {
|
2020-06-30 08:24:58 +00:00
|
|
|
for (let i = 0; i < this.length; i++) {
|
2016-05-06 13:23:51 +00:00
|
|
|
func(this[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-30 08:24:58 +00:00
|
|
|
let versions;
|
|
|
|
let pages;
|
|
|
|
let selectedPage;
|
|
|
|
let baselineVersion;
|
|
|
|
let selectedEntry;
|
2021-03-17 10:07:14 +00:00
|
|
|
let sortByLabel = false;
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-09-29 13:31:12 +00:00
|
|
|
// Marker to programatically replace the defaultData.
|
2021-03-17 10:07:14 +00:00
|
|
|
let defaultData = /*default-data-start*/ undefined /*default-data-end*/;
|
2016-05-06 13:23:51 +00:00
|
|
|
|
|
|
|
function initialize() {
|
2016-09-28 07:49:45 +00:00
|
|
|
// Initialize the stats table and toggle lists.
|
2020-06-30 08:24:58 +00:00
|
|
|
let original = $("column");
|
2021-03-02 13:56:46 +00:00
|
|
|
let viewBody = $("view").querySelector('.panelBody');
|
|
|
|
removeAllChildren(viewBody);
|
2020-06-30 08:24:58 +00:00
|
|
|
let i = 0;
|
2021-03-17 10:07:14 +00:00
|
|
|
versions.forEach((version) => {
|
2016-05-11 12:32:27 +00:00
|
|
|
if (!version.enabled) return;
|
2016-05-06 13:23:51 +00:00
|
|
|
// add column
|
2020-06-30 08:24:58 +00:00
|
|
|
let column = original.cloneNode(true);
|
2016-05-06 13:23:51 +00:00
|
|
|
column.id = "column_" + i;
|
|
|
|
// Fill in all versions
|
2020-06-30 08:24:58 +00:00
|
|
|
let select = column.querySelector(".version");
|
2016-05-06 13:23:51 +00:00
|
|
|
select.id = "selectVersion_" + i;
|
|
|
|
// add all select options
|
|
|
|
versions.forEach((version) => {
|
2016-05-11 12:32:27 +00:00
|
|
|
if (!version.enabled) return;
|
2020-06-30 08:24:58 +00:00
|
|
|
let option = document.createElement("option");
|
2016-05-06 13:23:51 +00:00
|
|
|
option.textContent = version.name;
|
|
|
|
option.version = version;
|
|
|
|
select.appendChild(option);
|
|
|
|
});
|
|
|
|
// Fill in all page versions
|
|
|
|
select = column.querySelector(".pageVersion");
|
|
|
|
select.id = "select_" + i;
|
2016-05-11 12:32:27 +00:00
|
|
|
// add all pages
|
2016-05-06 13:23:51 +00:00
|
|
|
versions.forEach((version) => {
|
2016-05-11 12:32:27 +00:00
|
|
|
if (!version.enabled) return;
|
2020-06-30 08:24:58 +00:00
|
|
|
let optgroup = document.createElement("optgroup");
|
2016-05-06 13:23:51 +00:00
|
|
|
optgroup.label = version.name;
|
|
|
|
optgroup.version = version;
|
2016-06-06 13:07:20 +00:00
|
|
|
version.forEachPage((page) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let option = document.createElement("option");
|
2016-05-06 13:23:51 +00:00
|
|
|
option.textContent = page.name;
|
|
|
|
option.page = page;
|
|
|
|
optgroup.appendChild(option);
|
|
|
|
});
|
|
|
|
select.appendChild(optgroup);
|
|
|
|
});
|
2021-03-02 13:56:46 +00:00
|
|
|
viewBody.appendChild(column);
|
2016-05-11 12:32:27 +00:00
|
|
|
i++;
|
|
|
|
});
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2020-06-30 08:24:58 +00:00
|
|
|
let select = $('baseline');
|
2016-05-06 13:23:51 +00:00
|
|
|
removeAllChildren(select);
|
|
|
|
select.appendChild(document.createElement('option'));
|
|
|
|
versions.forEach((version) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let option = document.createElement("option");
|
2016-05-06 13:23:51 +00:00
|
|
|
option.textContent = version.name;
|
|
|
|
option.version = version;
|
|
|
|
select.appendChild(option);
|
|
|
|
});
|
2016-06-06 13:07:20 +00:00
|
|
|
initializeToggleList(versions.versions, $('versionSelector'));
|
|
|
|
initializeToggleList(pages.values(), $('pageSelector'));
|
2016-09-28 07:49:45 +00:00
|
|
|
initializeToggleList(Group.groups.values(), $('groupSelector'));
|
2016-06-06 13:07:20 +00:00
|
|
|
}
|
2016-05-11 12:32:27 +00:00
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
function initializeToggleList(items, node) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let list = node.querySelector('ul');
|
2016-06-06 13:07:20 +00:00
|
|
|
removeAllChildren(list);
|
|
|
|
items = Array.from(items);
|
|
|
|
items.sort(NameComparator);
|
|
|
|
items.forEach((item) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let li = document.createElement('li');
|
|
|
|
let checkbox = document.createElement('input');
|
2016-05-11 12:32:27 +00:00
|
|
|
checkbox.type = 'checkbox';
|
2016-06-06 13:07:20 +00:00
|
|
|
checkbox.checked = item.enabled;
|
|
|
|
checkbox.item = item;
|
2016-09-28 07:49:45 +00:00
|
|
|
checkbox.addEventListener('click', handleToggleVersionOrPageEnable);
|
2016-05-11 12:32:27 +00:00
|
|
|
li.appendChild(checkbox);
|
2016-06-06 13:07:20 +00:00
|
|
|
li.appendChild(document.createTextNode(item.name));
|
|
|
|
list.appendChild(li);
|
2016-05-11 12:32:27 +00:00
|
|
|
});
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-11-22 10:12:53 +00:00
|
|
|
window.addEventListener('popstate', (event) => {
|
|
|
|
popHistoryState(event.state);
|
|
|
|
});
|
|
|
|
|
|
|
|
function popHistoryState(state) {
|
|
|
|
if (!state.version) return false;
|
|
|
|
if (!versions) return false;
|
2020-06-30 08:24:58 +00:00
|
|
|
let version = versions.getByName(state.version);
|
2016-11-22 10:12:53 +00:00
|
|
|
if (!version) return false;
|
2020-06-30 08:24:58 +00:00
|
|
|
let page = version.get(state.page);
|
2016-11-22 10:12:53 +00:00
|
|
|
if (!page) return false;
|
|
|
|
if (!state.entry) {
|
2017-03-01 13:28:06 +00:00
|
|
|
showEntry(page.total);
|
2016-11-22 10:12:53 +00:00
|
|
|
} else {
|
2020-06-30 08:24:58 +00:00
|
|
|
let entry = page.get(state.entry);
|
2016-11-22 10:12:53 +00:00
|
|
|
if (!entry) {
|
2017-03-01 13:28:06 +00:00
|
|
|
showEntry(page.total);
|
2016-11-22 10:12:53 +00:00
|
|
|
} else {
|
|
|
|
showEntry(entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function pushHistoryState() {
|
2020-06-30 08:24:58 +00:00
|
|
|
let selection = selectedEntry ? selectedEntry : selectedPage;
|
2016-11-22 10:12:53 +00:00
|
|
|
if (!selection) return;
|
2020-06-30 08:24:58 +00:00
|
|
|
let state = selection.urlParams();
|
2016-11-22 10:12:53 +00:00
|
|
|
// Don't push a history state if it didn't change.
|
|
|
|
if (JSON.stringify(window.history.state) === JSON.stringify(state)) return;
|
2020-06-30 08:24:58 +00:00
|
|
|
let params = "?";
|
|
|
|
for (let pairs of Object.entries(state)) {
|
2021-03-17 10:07:14 +00:00
|
|
|
params += encodeURIComponent(pairs[0]) + "=" +
|
|
|
|
encodeURIComponent(pairs[1]) + "&";
|
2016-11-22 10:12:53 +00:00
|
|
|
}
|
|
|
|
window.history.pushState(state, selection.toString(), params);
|
|
|
|
}
|
|
|
|
|
2017-03-01 13:28:06 +00:00
|
|
|
function showSelectedEntryInPage(page) {
|
|
|
|
if (!selectedEntry) return showPage(page);
|
2020-06-30 08:24:58 +00:00
|
|
|
let entry = page.get(selectedEntry.name);
|
2017-03-01 13:28:06 +00:00
|
|
|
if (!entry) return showPage(page);
|
|
|
|
selectEntry(entry);
|
|
|
|
}
|
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
function showPage(firstPage) {
|
2021-03-17 10:07:14 +00:00
|
|
|
let changeSelectedEntry = selectedEntry !== undefined &&
|
|
|
|
selectedEntry.page === selectedPage;
|
2016-05-06 13:23:51 +00:00
|
|
|
selectedPage = firstPage;
|
|
|
|
selectedPage.sort();
|
|
|
|
showPageInColumn(firstPage, 0);
|
|
|
|
// Show the other versions of this page in the following columns.
|
2020-06-30 08:24:58 +00:00
|
|
|
let pageVersions = versions.getPageVersions(firstPage);
|
|
|
|
let index = 1;
|
2016-05-06 13:23:51 +00:00
|
|
|
pageVersions.forEach((page) => {
|
|
|
|
if (page !== firstPage) {
|
|
|
|
showPageInColumn(page, index);
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
});
|
2016-05-11 12:32:27 +00:00
|
|
|
if (changeSelectedEntry) {
|
|
|
|
showEntryDetail(selectedPage.getEntry(selectedEntry));
|
|
|
|
}
|
2016-09-28 07:49:45 +00:00
|
|
|
showImpactList(selectedPage);
|
2016-11-22 10:12:53 +00:00
|
|
|
pushHistoryState();
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
|
2021-03-17 10:07:14 +00:00
|
|
|
function clamp(value, min, max) {
|
|
|
|
if (value < min) return min;
|
|
|
|
if (value > max) return max;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
function diffColorFromRatio(ratio) {
|
|
|
|
if (ratio > 1) {
|
|
|
|
// ratio > 1: #FFFFFF => #00FF00
|
2021-03-17 10:07:14 +00:00
|
|
|
const red = clamp(((ratio - 1) * 255 * 10) | 0, 0, 255);
|
|
|
|
const other = (255 - red).toString(16).padStart(2, '0');
|
|
|
|
return `#ff${other}${other}`;
|
2021-03-02 13:56:46 +00:00
|
|
|
}
|
|
|
|
// ratio < 1: #FF0000 => #FFFFFF
|
2021-03-17 10:07:14 +00:00
|
|
|
const green = clamp(((1 - ratio) * 255 * 10) | 0, 0, 255);
|
|
|
|
const other = (255 - green).toString(16).padStart(2, '0');
|
|
|
|
return `#${other}ff${other}`;
|
2021-03-02 13:56:46 +00:00
|
|
|
}
|
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
function showPageInColumn(page, columnIndex) {
|
|
|
|
page.sort();
|
2021-03-02 13:56:46 +00:00
|
|
|
let showDiff = columnIndex !== 0;
|
|
|
|
if (baselineVersion) showDiff = page.version !== baselineVersion;
|
2021-03-17 10:07:14 +00:00
|
|
|
let diffColor = (td, a, b) => { };
|
2016-05-06 13:23:51 +00:00
|
|
|
if (showDiff) {
|
2021-03-02 13:56:46 +00:00
|
|
|
if (baselineVersion) {
|
|
|
|
diffColor = (td, diff, baseline) => {
|
|
|
|
if (diff == 0) return;
|
2021-03-17 10:07:14 +00:00
|
|
|
const ratio = (baseline + diff) / baseline;
|
2021-03-02 13:56:46 +00:00
|
|
|
td.style.color = diffColorFromRatio(ratio);
|
2016-05-06 13:23:51 +00:00
|
|
|
};
|
|
|
|
} else {
|
2021-03-02 13:56:46 +00:00
|
|
|
diffColor = (td, value, reference) => {
|
|
|
|
if (value == reference) return;
|
|
|
|
const ratio = value / reference;
|
|
|
|
td.style.color = diffColorFromRatio(ratio);
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-30 08:24:58 +00:00
|
|
|
let column = $('column_' + columnIndex);
|
|
|
|
let select = $('select_' + columnIndex);
|
2016-05-06 13:23:51 +00:00
|
|
|
// Find the matching option
|
|
|
|
selectOption(select, (i, option) => {
|
|
|
|
return option.page == page
|
|
|
|
});
|
2020-06-30 08:24:58 +00:00
|
|
|
let table = column.querySelector("table");
|
|
|
|
let oldTbody = table.querySelector('tbody');
|
|
|
|
let tbody = document.createElement('tbody');
|
|
|
|
let referencePage = selectedPage;
|
2016-05-11 12:32:27 +00:00
|
|
|
page.forEachSorted(selectedPage, (parentEntry, entry, referenceEntry) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let tr = document.createElement('tr');
|
2016-05-06 13:23:51 +00:00
|
|
|
tbody.appendChild(tr);
|
|
|
|
tr.entry = entry;
|
|
|
|
tr.parentEntry = parentEntry;
|
2016-05-11 12:32:27 +00:00
|
|
|
tr.className = parentEntry === undefined ? 'parent' : 'child';
|
2016-05-06 13:23:51 +00:00
|
|
|
// Don't show entries that do not exist on the current page or if we
|
|
|
|
// compare against the current page
|
|
|
|
if (entry !== undefined && page.version !== baselineVersion) {
|
|
|
|
// If we show a diff, use the baselineVersion as the referenceEntry
|
|
|
|
if (baselineVersion !== undefined) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let baselineEntry = baselineVersion.getEntry(entry);
|
2016-05-06 13:23:51 +00:00
|
|
|
if (baselineEntry !== undefined) referenceEntry = baselineEntry
|
|
|
|
}
|
|
|
|
if (!parentEntry) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let node = td(tr, '<div class="toggle">►</div>', 'position');
|
2016-05-06 13:23:51 +00:00
|
|
|
node.firstChild.addEventListener('click', handleToggleGroup);
|
|
|
|
} else {
|
|
|
|
td(tr, entry.position == 0 ? '' : entry.position, 'position');
|
|
|
|
}
|
2016-06-06 13:07:20 +00:00
|
|
|
addCodeSearchButton(entry,
|
2021-03-17 10:07:14 +00:00
|
|
|
td(tr, entry.name, 'name ' + entry.cssClass()));
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
diffColor(
|
2016-05-06 13:23:51 +00:00
|
|
|
td(tr, ms(entry.time), 'value time'),
|
|
|
|
entry.time, referenceEntry.time);
|
2021-03-02 13:56:46 +00:00
|
|
|
diffColor(
|
2016-05-06 13:23:51 +00:00
|
|
|
td(tr, percent(entry.timePercent), 'value time'),
|
|
|
|
entry.time, referenceEntry.time);
|
2021-03-02 13:56:46 +00:00
|
|
|
diffColor(
|
2016-05-06 13:23:51 +00:00
|
|
|
td(tr, count(entry.count), 'value count'),
|
|
|
|
entry.count, referenceEntry.count);
|
2021-03-17 10:07:14 +00:00
|
|
|
} else if (baselineVersion !== undefined && referenceEntry &&
|
|
|
|
page.version !== baselineVersion) {
|
2016-05-06 13:23:51 +00:00
|
|
|
// Show comparison of entry that does not exist on the current page.
|
2016-06-06 13:07:20 +00:00
|
|
|
tr.entry = new Entry(0, referenceEntry.name);
|
|
|
|
tr.entry.page = page;
|
2016-05-06 13:23:51 +00:00
|
|
|
td(tr, '-', 'position');
|
|
|
|
td(tr, referenceEntry.name, 'name');
|
2021-03-02 13:56:46 +00:00
|
|
|
diffColor(
|
2017-03-01 13:28:06 +00:00
|
|
|
td(tr, ms(referenceEntry.time), 'value time'),
|
|
|
|
referenceEntry.time, 0);
|
2021-03-02 13:56:46 +00:00
|
|
|
diffColor(
|
2017-03-01 13:28:06 +00:00
|
|
|
td(tr, percent(referenceEntry.timePercent), 'value time'),
|
|
|
|
referenceEntry.timePercent, 0);
|
2021-03-02 13:56:46 +00:00
|
|
|
diffColor(
|
2017-03-01 13:28:06 +00:00
|
|
|
td(tr, count(referenceEntry.count), 'value count'),
|
|
|
|
referenceEntry.count, 0);
|
2016-05-06 13:23:51 +00:00
|
|
|
} else {
|
|
|
|
// Display empty entry / baseline entry
|
2020-06-30 08:24:58 +00:00
|
|
|
let showBaselineEntry = entry !== undefined;
|
2016-05-11 12:32:27 +00:00
|
|
|
if (showBaselineEntry) {
|
2016-05-06 13:23:51 +00:00
|
|
|
if (!parentEntry) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let node = td(tr, '<div class="toggle">►</div>', 'position');
|
2016-05-06 13:23:51 +00:00
|
|
|
node.firstChild.addEventListener('click', handleToggleGroup);
|
|
|
|
} else {
|
|
|
|
td(tr, entry.position == 0 ? '' : entry.position, 'position');
|
|
|
|
}
|
|
|
|
td(tr, entry.name, 'name');
|
2016-05-11 12:32:27 +00:00
|
|
|
td(tr, ms(entry.time, false), 'value time');
|
|
|
|
td(tr, percent(entry.timePercent, false), 'value time');
|
|
|
|
td(tr, count(entry.count, false), 'value count');
|
2016-05-06 13:23:51 +00:00
|
|
|
} else {
|
|
|
|
td(tr, '-', 'position');
|
2017-02-08 17:29:56 +00:00
|
|
|
td(tr, referenceEntry.name, 'name');
|
2016-05-11 12:32:27 +00:00
|
|
|
td(tr, '-', 'value time');
|
|
|
|
td(tr, '-', 'value time');
|
|
|
|
td(tr, '-', 'value count');
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
table.replaceChild(tbody, oldTbody);
|
2020-06-30 08:24:58 +00:00
|
|
|
let versionSelect = column.querySelector('select.version');
|
2016-05-06 13:23:51 +00:00
|
|
|
selectOption(versionSelect, (index, option) => {
|
|
|
|
return option.version == page.version
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-11-22 10:12:53 +00:00
|
|
|
function showEntry(entry) {
|
|
|
|
selectEntry(entry, true);
|
|
|
|
}
|
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
function selectEntry(entry, updateSelectedPage) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let needsPageSwitch = true;
|
2017-03-01 13:28:06 +00:00
|
|
|
if (updateSelectedPage && selectedPage) {
|
2016-05-06 13:23:51 +00:00
|
|
|
entry = selectedPage.version.getEntry(entry);
|
2017-03-01 13:28:06 +00:00
|
|
|
needsPageSwitch = updateSelectedPage && entry.page != selectedPage;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2020-06-30 08:24:58 +00:00
|
|
|
let rowIndex = 0;
|
2016-05-06 13:23:51 +00:00
|
|
|
// If clicked in the detail row change the first column to that page.
|
|
|
|
if (needsPageSwitch) showPage(entry.page);
|
2020-06-30 08:24:58 +00:00
|
|
|
let childNodes = $('column_0').querySelector('.list tbody').childNodes;
|
|
|
|
for (let i = 0; i < childNodes.length; i++) {
|
2017-02-08 17:29:56 +00:00
|
|
|
if (childNodes[i].entry !== undefined &&
|
2021-03-17 10:07:14 +00:00
|
|
|
childNodes[i].entry.name == entry.name) {
|
2016-05-06 13:23:51 +00:00
|
|
|
rowIndex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-06-30 08:24:58 +00:00
|
|
|
let firstEntry = childNodes[rowIndex].entry;
|
2016-05-06 13:23:51 +00:00
|
|
|
if (rowIndex) {
|
|
|
|
if (firstEntry.parent) showGroup(firstEntry.parent);
|
|
|
|
}
|
|
|
|
// Deselect all
|
|
|
|
$('view').querySelectorAll('.list tbody tr').forEach((tr) => {
|
|
|
|
toggleCssClass(tr, 'selected', false);
|
|
|
|
});
|
|
|
|
// Select the entry row
|
|
|
|
$('view').querySelectorAll("tbody").forEach((body) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let row = body.childNodes[rowIndex];
|
2016-05-06 13:23:51 +00:00
|
|
|
if (!row) return;
|
2016-05-11 12:32:27 +00:00
|
|
|
toggleCssClass(row, 'selected', row.entry && row.entry.name ==
|
|
|
|
firstEntry.name);
|
2016-05-06 13:23:51 +00:00
|
|
|
});
|
2017-03-01 13:28:06 +00:00
|
|
|
if (updateSelectedPage && selectedEntry) {
|
2016-05-06 13:23:51 +00:00
|
|
|
entry = selectedEntry.page.version.getEntry(entry);
|
|
|
|
}
|
2017-03-01 13:28:06 +00:00
|
|
|
if (entry !== selectedEntry) {
|
|
|
|
selectedEntry = entry;
|
|
|
|
showEntryDetail(entry);
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function showEntryDetail(entry) {
|
2016-06-06 13:07:20 +00:00
|
|
|
showVersionDetails(entry);
|
|
|
|
showPageDetails(entry);
|
|
|
|
showImpactList(entry.page);
|
|
|
|
showGraphs(entry.page);
|
2016-11-22 10:12:53 +00:00
|
|
|
pushHistoryState();
|
2016-06-06 13:07:20 +00:00
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
function showVersionDetails(entry) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let table, tbody, entries;
|
2021-03-02 13:56:46 +00:00
|
|
|
table = $('versionDetails').querySelector('.versionDetailTable');
|
2016-05-06 13:23:51 +00:00
|
|
|
tbody = document.createElement('tbody');
|
|
|
|
if (entry !== undefined) {
|
2021-03-02 13:56:46 +00:00
|
|
|
$('versionDetails').querySelector('h2 span').textContent =
|
2016-06-06 13:07:20 +00:00
|
|
|
entry.name + ' in ' + entry.page.name;
|
|
|
|
entries = versions.getPageVersions(entry.page).map(
|
2016-05-06 13:23:51 +00:00
|
|
|
(page) => {
|
|
|
|
return page.get(entry.name)
|
|
|
|
});
|
|
|
|
entries.sort((a, b) => {
|
|
|
|
return a.time - b.time
|
|
|
|
});
|
|
|
|
entries.forEach((pageEntry) => {
|
|
|
|
if (pageEntry === undefined) return;
|
2020-06-30 08:24:58 +00:00
|
|
|
let tr = document.createElement('tr');
|
2016-05-06 13:23:51 +00:00
|
|
|
if (pageEntry == entry) tr.className += 'selected';
|
|
|
|
tr.entry = pageEntry;
|
2020-06-30 08:24:58 +00:00
|
|
|
let isBaselineEntry = pageEntry.page.version == baselineVersion;
|
2016-05-06 13:23:51 +00:00
|
|
|
td(tr, pageEntry.page.version.name, 'version');
|
2016-06-06 13:07:20 +00:00
|
|
|
td(tr, ms(pageEntry.time, !isBaselineEntry), 'value time');
|
|
|
|
td(tr, percent(pageEntry.timePercent, !isBaselineEntry), 'value time');
|
|
|
|
td(tr, count(pageEntry.count, !isBaselineEntry), 'value count');
|
2016-05-06 13:23:51 +00:00
|
|
|
tbody.appendChild(tr);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
table.replaceChild(tbody, table.querySelector('tbody'));
|
2016-06-06 13:07:20 +00:00
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
function showPageDetails(entry) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let table, tbody, entries;
|
2021-03-02 13:56:46 +00:00
|
|
|
table = $('pageDetail').querySelector('.pageDetailTable');
|
2016-05-06 13:23:51 +00:00
|
|
|
tbody = document.createElement('tbody');
|
2016-06-06 13:07:20 +00:00
|
|
|
if (entry === undefined) {
|
|
|
|
table.replaceChild(tbody, table.querySelector('tbody'));
|
|
|
|
return;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2020-06-30 08:24:58 +00:00
|
|
|
let version = entry.page.version;
|
|
|
|
let showDiff = version !== baselineVersion;
|
2021-03-02 13:56:46 +00:00
|
|
|
$('pageDetail').querySelector('h2 span').textContent =
|
2016-06-06 13:07:20 +00:00
|
|
|
version.name;
|
|
|
|
entries = version.pages.map((page) => {
|
2021-03-17 10:07:14 +00:00
|
|
|
if (!page.enabled) return;
|
|
|
|
return page.get(entry.name)
|
|
|
|
});
|
2016-06-06 13:07:20 +00:00
|
|
|
entries.sort((a, b) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let cmp = b.timePercent - a.timePercent;
|
2016-06-06 13:07:20 +00:00
|
|
|
if (cmp.toFixed(1) == 0) return b.time - a.time;
|
|
|
|
return cmp
|
|
|
|
});
|
|
|
|
entries.forEach((pageEntry) => {
|
|
|
|
if (pageEntry === undefined) return;
|
2020-06-30 08:24:58 +00:00
|
|
|
let tr = document.createElement('tr');
|
2016-06-06 13:07:20 +00:00
|
|
|
if (pageEntry === entry) tr.className += 'selected';
|
|
|
|
tr.entry = pageEntry;
|
|
|
|
td(tr, pageEntry.page.name, 'name');
|
|
|
|
td(tr, ms(pageEntry.time, showDiff), 'value time');
|
|
|
|
td(tr, percent(pageEntry.timePercent, showDiff), 'value time');
|
|
|
|
td(tr, percent(pageEntry.timePercentPerEntry, showDiff),
|
2021-03-17 10:07:14 +00:00
|
|
|
'value time hideNoDiff');
|
2016-06-06 13:07:20 +00:00
|
|
|
td(tr, count(pageEntry.count, showDiff), 'value count');
|
|
|
|
tbody.appendChild(tr);
|
|
|
|
});
|
|
|
|
// show the total for all pages
|
2020-06-30 08:24:58 +00:00
|
|
|
let tds = table.querySelectorAll('tfoot td');
|
2016-09-22 20:58:11 +00:00
|
|
|
tds[1].textContent = ms(entry.getTimeImpact(), showDiff);
|
2016-06-06 13:07:20 +00:00
|
|
|
// Only show the percentage total if we are in diff mode:
|
2016-09-22 20:58:11 +00:00
|
|
|
tds[2].textContent = percent(entry.getTimePercentImpact(), showDiff);
|
|
|
|
tds[3].textContent = '';
|
|
|
|
tds[4].textContent = count(entry.getCountImpact(), showDiff);
|
2016-05-06 13:23:51 +00:00
|
|
|
table.replaceChild(tbody, table.querySelector('tbody'));
|
|
|
|
}
|
|
|
|
|
|
|
|
function showImpactList(page) {
|
2021-03-02 13:56:46 +00:00
|
|
|
let impactView = $('impactView');
|
|
|
|
impactView.querySelector('h2 span').textContent = page.version.name;
|
2016-05-06 13:23:51 +00:00
|
|
|
|
2020-06-30 08:24:58 +00:00
|
|
|
let table = impactView.querySelector('table');
|
|
|
|
let tbody = document.createElement('tbody');
|
|
|
|
let version = page.version;
|
|
|
|
let entries = version.allEntries();
|
2016-05-06 13:23:51 +00:00
|
|
|
if (selectedEntry !== undefined && selectedEntry.isGroup) {
|
2021-03-02 13:56:46 +00:00
|
|
|
impactView.querySelector('h2 span').textContent += " " + selectedEntry.name;
|
2016-05-06 13:23:51 +00:00
|
|
|
entries = entries.filter((entry) => {
|
|
|
|
return entry.name == selectedEntry.name ||
|
|
|
|
(entry.parent && entry.parent.name == selectedEntry.name)
|
|
|
|
});
|
|
|
|
}
|
2020-06-30 08:24:58 +00:00
|
|
|
let isCompareView = baselineVersion !== undefined;
|
2016-05-11 12:32:27 +00:00
|
|
|
entries = entries.filter((entry) => {
|
|
|
|
if (isCompareView) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let impact = entry.getTimeImpact();
|
2016-05-11 12:32:27 +00:00
|
|
|
return impact < -1 || 1 < impact
|
|
|
|
}
|
2017-03-09 09:53:34 +00:00
|
|
|
return entry.getTimePercentImpact() > 0.01;
|
2016-05-11 12:32:27 +00:00
|
|
|
});
|
2017-03-09 09:53:34 +00:00
|
|
|
entries = entries.slice(0, 50);
|
2016-05-06 13:23:51 +00:00
|
|
|
entries.sort((a, b) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let cmp = b.getTimePercentImpact() - a.getTimePercentImpact();
|
2016-05-11 12:32:27 +00:00
|
|
|
if (isCompareView || cmp.toFixed(1) == 0) {
|
|
|
|
return b.getTimeImpact() - a.getTimeImpact();
|
|
|
|
}
|
|
|
|
return cmp
|
2016-05-06 13:23:51 +00:00
|
|
|
});
|
|
|
|
entries.forEach((entry) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let tr = document.createElement('tr');
|
2016-05-06 13:23:51 +00:00
|
|
|
tr.entry = entry;
|
|
|
|
td(tr, entry.name, 'name');
|
|
|
|
td(tr, ms(entry.getTimeImpact()), 'value time');
|
2020-06-30 08:24:58 +00:00
|
|
|
let percentImpact = entry.getTimePercentImpact();
|
2016-05-11 12:32:27 +00:00
|
|
|
td(tr, percentImpact > 1000 ? '-' : percent(percentImpact), 'value time');
|
2020-06-30 08:24:58 +00:00
|
|
|
let topPages = entry.getPagesByPercentImpact().slice(0, 3)
|
2016-05-06 13:23:51 +00:00
|
|
|
.map((each) => {
|
2016-05-11 12:32:27 +00:00
|
|
|
return each.name + ' (' + percent(each.getEntry(entry).timePercent) +
|
|
|
|
')'
|
2016-05-06 13:23:51 +00:00
|
|
|
});
|
|
|
|
td(tr, topPages.join(', '), 'name');
|
|
|
|
tbody.appendChild(tr);
|
|
|
|
});
|
|
|
|
table.replaceChild(tbody, table.querySelector('tbody'));
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
function showGraphs(page) {
|
2021-02-08 11:37:32 +00:00
|
|
|
let groups = page.groups.filter(each => each.enabled && !each.isTotal);
|
2016-06-06 13:07:20 +00:00
|
|
|
// Sort groups by the biggest impact
|
2021-02-08 11:37:32 +00:00
|
|
|
groups.sort((a, b) => b.getTimeImpact() - a.getTimeImpact());
|
2016-05-11 12:32:27 +00:00
|
|
|
if (selectedGroup == undefined) {
|
|
|
|
selectedGroup = groups[0];
|
|
|
|
} else {
|
2017-03-09 09:53:34 +00:00
|
|
|
groups = groups.filter(each => each.name != selectedGroup.name);
|
2021-02-08 11:37:32 +00:00
|
|
|
if (!selectedGroup.isTotal && selectedGroup.enabled) {
|
|
|
|
groups.unshift(selectedGroup);
|
|
|
|
}
|
2016-05-11 12:32:27 +00:00
|
|
|
}
|
2021-02-08 11:37:32 +00:00
|
|
|
// Display graphs delayed for a snappier UI.
|
|
|
|
setTimeout(() => {
|
2021-03-17 10:07:14 +00:00
|
|
|
showPageVersionGraph(groups, page);
|
|
|
|
showPageGraph(groups, page);
|
|
|
|
showVersionGraph(groups, page);
|
|
|
|
}, 10);
|
2016-06-06 13:07:20 +00:00
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2021-02-08 11:37:32 +00:00
|
|
|
function getGraphDataTable(groups, page) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let dataTable = new google.visualization.DataTable();
|
2016-05-11 12:32:27 +00:00
|
|
|
dataTable.addColumn('string', 'Name');
|
|
|
|
groups.forEach(group => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let column = dataTable.addColumn('number', group.name.substring(6));
|
2016-05-11 12:32:27 +00:00
|
|
|
dataTable.setColumnProperty(column, 'group', group);
|
2021-03-17 10:07:14 +00:00
|
|
|
column = dataTable.addColumn({
|
|
|
|
role: "annotation"
|
|
|
|
});
|
2021-02-08 11:37:32 +00:00
|
|
|
dataTable.setColumnProperty(column, 'group', group);
|
2016-05-11 12:32:27 +00:00
|
|
|
});
|
2021-02-08 11:37:32 +00:00
|
|
|
let column = dataTable.addColumn('number', 'Chart Total');
|
|
|
|
dataTable.setColumnProperty(column, 'group', page.total);
|
2021-03-17 10:07:14 +00:00
|
|
|
column = dataTable.addColumn({
|
|
|
|
role: "annotation"
|
|
|
|
});
|
2021-02-08 11:37:32 +00:00
|
|
|
dataTable.setColumnProperty(column, 'group', page.total);
|
2016-06-06 13:07:20 +00:00
|
|
|
return dataTable;
|
|
|
|
}
|
|
|
|
|
2020-06-30 08:24:58 +00:00
|
|
|
let selectedGroup;
|
2021-02-08 11:37:32 +00:00
|
|
|
|
|
|
|
class ChartRow {
|
|
|
|
static kSortFirstValueRelative(chartRow) {
|
2021-03-17 10:07:14 +00:00
|
|
|
if (selectedGroup?.isTotal) return chartRow.total;
|
2021-02-08 11:37:32 +00:00
|
|
|
return chartRow.data[0] / chartRow.total;
|
|
|
|
}
|
|
|
|
|
|
|
|
static kSortByFirstValue(chartRow) {
|
2021-03-17 10:07:14 +00:00
|
|
|
if (selectedGroup?.isTotal) return chartRow.total;
|
2021-02-08 11:37:32 +00:00
|
|
|
return chartRow.data[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(linkedPage, label, sortValue_fn, data,
|
2021-03-17 10:07:14 +00:00
|
|
|
excludeFromAverage = false) {
|
2021-02-08 11:37:32 +00:00
|
|
|
this.linkedPage = linkedPage;
|
|
|
|
this.label = label;
|
|
|
|
if (!Array.isArray(data)) {
|
|
|
|
throw new Error("Provide an Array for data");
|
|
|
|
}
|
|
|
|
this.data = data;
|
|
|
|
this.total = 0;
|
|
|
|
for (let i = 0; i < data.length; i++) this.total += data[i];
|
|
|
|
this.sortValue = sortValue_fn(this);
|
|
|
|
this.excludeFromAverage = excludeFromAverage;
|
|
|
|
}
|
|
|
|
|
|
|
|
forDataTable(maxRowsTotal) {
|
|
|
|
// row = [label, entry1, annotation1, entry2, annotation2, ...]
|
|
|
|
const rowData = [this.label];
|
|
|
|
const kShowLabelLimit = 0.1;
|
|
|
|
const kMinLabelWidth = 80;
|
|
|
|
const chartWidth = window.innerWidth - 400;
|
|
|
|
// Add value,label pairs
|
|
|
|
for (let i = 0; i < this.data.length; i++) {
|
|
|
|
const value = this.data[i];
|
|
|
|
let label = '';
|
|
|
|
// Only show labels for entries that are large enough..
|
2021-03-17 10:07:14 +00:00
|
|
|
if (Math.abs(value / maxRowsTotal) * chartWidth > kMinLabelWidth) {
|
2021-02-08 11:37:32 +00:00
|
|
|
label = ms(value);
|
|
|
|
}
|
|
|
|
rowData.push(value, label);
|
|
|
|
}
|
|
|
|
// Add the total row, with very small negative dummy entry for correct
|
|
|
|
// placement of labels in diff view.
|
|
|
|
rowData.push(this.total >= 0 ? 0 : -0.000000001, ms(this.total));
|
|
|
|
return rowData;
|
|
|
|
}
|
|
|
|
}
|
2021-03-17 10:07:14 +00:00
|
|
|
const collator = new Intl.Collator('en-UK');
|
2021-02-08 11:37:32 +00:00
|
|
|
|
|
|
|
function setDataTableRows(dataTable, rows) {
|
|
|
|
let skippedRows = 0;
|
|
|
|
// Always sort by the selected entry (first column after the label)
|
2021-03-17 10:07:14 +00:00
|
|
|
if (sortByLabel) {
|
|
|
|
rows.sort((a, b) => collator.compare(a.label, b.label));
|
|
|
|
} else {
|
|
|
|
rows.sort((a, b) => b.sortValue - a.sortValue);
|
|
|
|
}
|
2021-02-08 11:37:32 +00:00
|
|
|
// Aggregate row data for Average/SUM chart entry:
|
|
|
|
const aggregateData = rows[0].data.slice().fill(0);
|
|
|
|
let maxTotal = 0;
|
|
|
|
for (let i = 0; i < rows.length; i++) {
|
|
|
|
const row = rows[i];
|
|
|
|
let total = Math.abs(row.total);
|
|
|
|
if (total > maxTotal) maxTotal = total;
|
|
|
|
if (row.excludeFromAverage) {
|
|
|
|
skippedRows++;
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
const chartRowData = row.data;
|
|
|
|
for (let j = 0; j < chartRowData.length; j++) {
|
|
|
|
aggregateData[j] += chartRowData[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const length = rows.length - skippedRows;
|
|
|
|
for (let i = 0; i < aggregateData.length; i++) {
|
|
|
|
aggregateData[i] /= rows.length;
|
|
|
|
}
|
|
|
|
const averageRow = new ChartRow(undefined, 'Average',
|
2021-03-17 10:07:14 +00:00
|
|
|
ChartRow.kSortByFirstValue, aggregateData);
|
2021-02-08 11:37:32 +00:00
|
|
|
dataTable.addRow(averageRow.forDataTable());
|
|
|
|
|
|
|
|
rows.forEach(chartRow => {
|
|
|
|
let rowIndex = dataTable.addRow(chartRow.forDataTable(maxTotal));
|
|
|
|
dataTable.setRowProperty(rowIndex, 'page', chartRow.linkedPage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function showPageVersionGraph(groups, page) {
|
|
|
|
let dataTable = getGraphDataTable(groups, page);
|
|
|
|
let vs = versions.getPageVersions(page);
|
|
|
|
// Calculate the entries for the versions
|
|
|
|
const rows = vs.map(page => new ChartRow(
|
2021-03-17 10:07:14 +00:00
|
|
|
page, page.version.name, ChartRow.kSortByFirstValue,
|
|
|
|
groups.map(group => page.getEntry(group).time),
|
|
|
|
page.version === baselineVersion));
|
2021-02-08 11:37:32 +00:00
|
|
|
renderGraph(`Versions for ${page.name}`, groups, dataTable, rows,
|
2021-03-17 10:07:14 +00:00
|
|
|
'pageVersionGraph', true);
|
2021-02-08 11:37:32 +00:00
|
|
|
}
|
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
function showPageGraph(groups, page) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let isDiffView = baselineVersion !== undefined;
|
2021-02-08 11:37:32 +00:00
|
|
|
let dataTable = getGraphDataTable(groups, page);
|
2016-05-11 12:32:27 +00:00
|
|
|
// Calculate the average row
|
|
|
|
// Sort the pages by the selected group.
|
2020-06-30 08:24:58 +00:00
|
|
|
let pages = page.version.pages.filter(page => page.enabled);
|
2016-05-11 12:32:27 +00:00
|
|
|
// Calculate the entries for the pages
|
2021-02-08 11:37:32 +00:00
|
|
|
const rows = pages.map(page => new ChartRow(
|
2021-03-17 10:07:14 +00:00
|
|
|
page, page.name,
|
|
|
|
isDiffView ?
|
|
|
|
ChartRow.kSortByFirstValue : ChartRow.kSortFirstValueRelative,
|
|
|
|
groups.map(group => page.getEntry(group).time)));
|
2021-02-08 11:37:32 +00:00
|
|
|
renderGraph(`Pages for ${page.version.name}`, groups, dataTable, rows,
|
2021-03-17 10:07:14 +00:00
|
|
|
'pageGraph', isDiffView ? true : 'percent');
|
2016-06-06 13:07:20 +00:00
|
|
|
}
|
2016-05-11 12:32:27 +00:00
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
function showVersionGraph(groups, page) {
|
2021-02-08 11:37:32 +00:00
|
|
|
let dataTable = getGraphDataTable(groups, page);
|
2020-06-30 08:24:58 +00:00
|
|
|
let vs = versions.versions.filter(version => version.enabled);
|
2017-02-08 17:29:56 +00:00
|
|
|
// Calculate the entries for the versions
|
2021-02-08 11:37:32 +00:00
|
|
|
const rows = vs.map((version) => new ChartRow(
|
2021-03-17 10:07:14 +00:00
|
|
|
version.get(page), version.name, ChartRow.kSortByFirstValue,
|
|
|
|
groups.map(group => version.getEntry(group).getTimeImpact()),
|
|
|
|
version === baselineVersion));
|
2021-02-08 11:37:32 +00:00
|
|
|
renderGraph('Versions Total Time over all Pages', groups, dataTable, rows,
|
2021-03-17 10:07:14 +00:00
|
|
|
'versionGraph', true);
|
2016-06-06 13:07:20 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 11:37:32 +00:00
|
|
|
function renderGraph(title, groups, dataTable, rows, id, isStacked) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let isDiffView = baselineVersion !== undefined;
|
2021-02-08 11:37:32 +00:00
|
|
|
setDataTableRows(dataTable, rows);
|
2020-06-30 08:24:58 +00:00
|
|
|
let formatter = new google.visualization.NumberFormat({
|
2017-02-08 17:29:56 +00:00
|
|
|
suffix: (isDiffView ? 'msΔ' : 'ms'),
|
|
|
|
negativeColor: 'red',
|
2016-06-06 13:07:20 +00:00
|
|
|
groupingSymbol: "'"
|
|
|
|
});
|
2020-06-30 08:24:58 +00:00
|
|
|
for (let i = 1; i < dataTable.getNumberOfColumns(); i++) {
|
2016-06-06 13:07:20 +00:00
|
|
|
formatter.format(dataTable, i);
|
|
|
|
}
|
2020-06-30 08:24:58 +00:00
|
|
|
let height = 85 + 28 * dataTable.getNumberOfRows();
|
|
|
|
let options = {
|
2016-06-06 13:07:20 +00:00
|
|
|
isStacked: isStacked,
|
|
|
|
height: height,
|
2016-05-11 12:32:27 +00:00
|
|
|
hAxis: {
|
|
|
|
minValue: 0,
|
2021-03-17 10:07:14 +00:00
|
|
|
textStyle: {
|
|
|
|
fontSize: 14
|
|
|
|
}
|
2016-05-11 12:32:27 +00:00
|
|
|
},
|
|
|
|
vAxis: {
|
2021-03-17 10:07:14 +00:00
|
|
|
textStyle: {
|
|
|
|
fontSize: 14
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tooltip: {
|
|
|
|
textStyle: {
|
|
|
|
fontSize: 14
|
|
|
|
}
|
|
|
|
},
|
|
|
|
annotations: {
|
|
|
|
textStyle: {
|
|
|
|
fontSize: 8
|
|
|
|
}
|
2016-06-06 13:07:20 +00:00
|
|
|
},
|
|
|
|
explorer: {
|
|
|
|
actions: ['dragToZoom', 'rightClickToReset'],
|
|
|
|
maxZoomIn: 0.01
|
|
|
|
},
|
2021-03-17 10:07:14 +00:00
|
|
|
legend: {
|
|
|
|
position: 'top',
|
|
|
|
maxLines: 3,
|
|
|
|
textStyle: {
|
|
|
|
fontSize: 12
|
|
|
|
}
|
|
|
|
},
|
|
|
|
chartArea: {
|
|
|
|
left: 200,
|
|
|
|
top: 50
|
|
|
|
},
|
|
|
|
colors: [
|
|
|
|
...groups.map(each => each.color),
|
|
|
|
/* Chart Total */
|
|
|
|
"#000000",
|
|
|
|
]
|
2016-05-11 12:32:27 +00:00
|
|
|
};
|
2020-06-30 08:24:58 +00:00
|
|
|
let parentNode = $(id);
|
2016-09-22 20:58:11 +00:00
|
|
|
parentNode.querySelector('h2>span, h3>span').textContent = title;
|
2021-03-02 13:56:46 +00:00
|
|
|
let graphNode = parentNode.querySelector('.panelBody');
|
2016-06-06 13:07:20 +00:00
|
|
|
|
2020-06-30 08:24:58 +00:00
|
|
|
let chart = graphNode.chart;
|
2016-06-06 13:07:20 +00:00
|
|
|
if (chart === undefined) {
|
|
|
|
chart = graphNode.chart = new google.visualization.BarChart(graphNode);
|
|
|
|
} else {
|
|
|
|
google.visualization.events.removeAllListeners(chart);
|
|
|
|
}
|
2016-05-11 12:32:27 +00:00
|
|
|
google.visualization.events.addListener(chart, 'select', selectHandler);
|
2021-03-17 10:07:14 +00:00
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
function getChartEntry(selection) {
|
|
|
|
if (!selection) return undefined;
|
2020-06-30 08:24:58 +00:00
|
|
|
let column = selection.column;
|
2016-06-06 13:07:20 +00:00
|
|
|
if (column == undefined) return undefined;
|
2020-06-30 08:24:58 +00:00
|
|
|
let selectedGroup = dataTable.getColumnProperty(column, 'group');
|
|
|
|
let row = selection.row;
|
2016-06-06 13:07:20 +00:00
|
|
|
if (row == null) return selectedGroup;
|
2020-06-30 08:24:58 +00:00
|
|
|
let page = dataTable.getRowProperty(row, 'page');
|
2016-06-06 13:07:20 +00:00
|
|
|
if (!page) return selectedGroup;
|
|
|
|
return page.getEntry(selectedGroup);
|
|
|
|
}
|
2021-03-17 10:07:14 +00:00
|
|
|
|
2021-02-08 11:37:32 +00:00
|
|
|
function selectHandler(e) {
|
2021-03-17 10:07:14 +00:00
|
|
|
const newSelectedGroup = getChartEntry(chart.getSelection()[0]);
|
|
|
|
if (newSelectedGroup == selectedGroup) {
|
|
|
|
sortByLabel = !sortByLabel;
|
|
|
|
} else if (newSelectedGroup === undefined && selectedPage) {
|
|
|
|
sortByLabel = true;
|
|
|
|
return showGraphs(selectedPage);
|
|
|
|
} else {
|
|
|
|
sortByLabel = false;
|
|
|
|
}
|
|
|
|
selectedGroup = newSelectedGroup;
|
2016-06-06 13:07:20 +00:00
|
|
|
selectEntry(selectedGroup, true);
|
2016-05-11 12:32:27 +00:00
|
|
|
}
|
2016-06-06 13:07:20 +00:00
|
|
|
|
|
|
|
// Make our global tooltips work
|
|
|
|
google.visualization.events.addListener(chart, 'onmouseover', mouseOverHandler);
|
2021-03-17 10:07:14 +00:00
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
function mouseOverHandler(selection) {
|
2021-03-17 10:07:14 +00:00
|
|
|
const selectedGroup = getChartEntry(selection);
|
|
|
|
graphNode.entry = selectedGroup;
|
2016-06-06 13:07:20 +00:00
|
|
|
}
|
|
|
|
chart.draw(dataTable, options);
|
2016-05-11 12:32:27 +00:00
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
|
|
|
|
function showGroup(entry) {
|
|
|
|
toggleGroup(entry, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleGroup(group, show) {
|
|
|
|
$('view').querySelectorAll(".child").forEach((tr) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let entry = tr.parentEntry;
|
2016-05-06 13:23:51 +00:00
|
|
|
if (!entry) return;
|
|
|
|
if (entry.name !== group.name) return;
|
|
|
|
toggleCssClass(tr, 'visible', show);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function showPopover(entry) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let popover = $('popover');
|
2016-09-22 20:58:11 +00:00
|
|
|
popover.querySelector('td.name').textContent = entry.name;
|
|
|
|
popover.querySelector('td.page').textContent = entry.page.name;
|
2016-05-06 13:23:51 +00:00
|
|
|
setPopoverDetail(popover, entry, '');
|
|
|
|
popover.querySelector('table').className = "";
|
|
|
|
if (baselineVersion !== undefined) {
|
|
|
|
entry = baselineVersion.getEntry(entry);
|
|
|
|
setPopoverDetail(popover, entry, '.compare');
|
|
|
|
popover.querySelector('table').className = "compare";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setPopoverDetail(popover, entry, prefix) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let node = (name) => popover.querySelector(prefix + name);
|
2016-05-11 12:32:27 +00:00
|
|
|
if (entry == undefined) {
|
2016-09-22 20:58:11 +00:00
|
|
|
node('.version').textContent = baselineVersion.name;
|
|
|
|
node('.time').textContent = '-';
|
|
|
|
node('.timeVariance').textContent = '-';
|
|
|
|
node('.percent').textContent = '-';
|
|
|
|
node('.percentPerEntry').textContent = '-';
|
2021-03-17 10:07:14 +00:00
|
|
|
node('.percentVariance').textContent = '-';
|
|
|
|
node('.count').textContent = '-';
|
2016-09-22 20:58:11 +00:00
|
|
|
node('.countVariance').textContent = '-';
|
|
|
|
node('.timeImpact').textContent = '-';
|
|
|
|
node('.timePercentImpact').textContent = '-';
|
2016-05-11 12:32:27 +00:00
|
|
|
} else {
|
2016-09-22 20:58:11 +00:00
|
|
|
node('.version').textContent = entry.page.version.name;
|
|
|
|
node('.time').textContent = ms(entry._time, false);
|
2021-03-17 10:07:14 +00:00
|
|
|
node('.timeVariance').textContent = percent(entry.timeVariancePercent, false);
|
2016-09-22 20:58:11 +00:00
|
|
|
node('.percent').textContent = percent(entry.timePercent, false);
|
2021-03-17 10:07:14 +00:00
|
|
|
node('.percentPerEntry').textContent = percent(entry.timePercentPerEntry, false);
|
|
|
|
node('.percentVariance').textContent = percent(entry.timePercentVariancePercent, false);
|
2016-09-22 20:58:11 +00:00
|
|
|
node('.count').textContent = count(entry._count, false);
|
2021-03-17 10:07:14 +00:00
|
|
|
node('.countVariance').textContent = percent(entry.timeVariancePercent, false);
|
|
|
|
node('.timeImpact').textContent = ms(entry.getTimeImpact(false), false);
|
|
|
|
node('.timePercentImpact').textContent = percent(entry.getTimeImpactVariancePercent(false), false);
|
2016-05-11 12:32:27 +00:00
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2016-06-06 13:07:20 +00:00
|
|
|
</script>
|
2019-01-04 12:18:43 +00:00
|
|
|
<script>
|
2021-03-17 10:07:14 +00:00
|
|
|
"use strict"
|
2016-06-06 13:07:20 +00:00
|
|
|
// =========================================================================
|
2016-05-06 13:23:51 +00:00
|
|
|
// Helpers
|
|
|
|
function $(id) {
|
|
|
|
return document.getElementById(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeAllChildren(node) {
|
|
|
|
while (node.firstChild) {
|
|
|
|
node.removeChild(node.firstChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectOption(select, match) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let options = select.options;
|
|
|
|
for (let i = 0; i < options.length; i++) {
|
2016-05-06 13:23:51 +00:00
|
|
|
if (match(i, options[i])) {
|
|
|
|
select.selectedIndex = i;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
function addCodeSearchButton(entry, node) {
|
|
|
|
if (entry.isGroup) return;
|
2020-06-30 08:24:58 +00:00
|
|
|
let button = document.createElement("div");
|
2016-09-22 20:58:11 +00:00
|
|
|
button.textContent = '?'
|
2016-06-06 13:07:20 +00:00
|
|
|
button.className = "codeSearch"
|
|
|
|
button.addEventListener('click', handleCodeSearch);
|
|
|
|
node.appendChild(button);
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
function td(tr, content, className) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let td = document.createElement("td");
|
2016-09-22 20:58:11 +00:00
|
|
|
if (content[0] == '<') {
|
|
|
|
td.innerHTML = content;
|
|
|
|
} else {
|
|
|
|
td.textContent = content;
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
td.className = className
|
|
|
|
tr.appendChild(td);
|
|
|
|
return td
|
|
|
|
}
|
|
|
|
|
|
|
|
function nodeIndex(node) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let children = node.parentNode.childNodes,
|
2016-05-06 13:23:51 +00:00
|
|
|
i = 0;
|
|
|
|
for (; i < children.length; i++) {
|
|
|
|
if (children[i] == node) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-03-17 10:07:14 +00:00
|
|
|
function toggleCssClass(node, cssClass, toggleState = true) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let index = -1;
|
|
|
|
let classes;
|
2016-05-06 13:23:51 +00:00
|
|
|
if (node.className != undefined) {
|
|
|
|
classes = node.className.split(' ');
|
|
|
|
index = classes.indexOf(cssClass);
|
|
|
|
}
|
|
|
|
if (index == -1) {
|
|
|
|
if (toggleState === false) return;
|
|
|
|
node.className += ' ' + cssClass;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (toggleState === true) return;
|
|
|
|
classes.splice(index, 1);
|
|
|
|
node.className = classes.join(' ');
|
|
|
|
}
|
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
function NameComparator(a, b) {
|
|
|
|
if (a.name > b.name) return 1;
|
|
|
|
if (a.name < b.name) return -1;
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2016-05-11 12:32:27 +00:00
|
|
|
function diffSign(value, digits, unit, showDiff) {
|
|
|
|
if (showDiff === false || baselineVersion == undefined) {
|
2016-06-06 13:07:20 +00:00
|
|
|
if (value === undefined) return '';
|
2016-05-11 12:32:27 +00:00
|
|
|
return value.toFixed(digits) + unit;
|
|
|
|
}
|
|
|
|
return (value >= 0 ? '+' : '') + value.toFixed(digits) + unit + 'Δ';
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-05-11 12:32:27 +00:00
|
|
|
function ms(value, showDiff) {
|
|
|
|
return diffSign(value, 1, 'ms', showDiff);
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-05-11 12:32:27 +00:00
|
|
|
function count(value, showDiff) {
|
|
|
|
return diffSign(value, 0, '#', showDiff);
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-05-11 12:32:27 +00:00
|
|
|
function percent(value, showDiff) {
|
|
|
|
return diffSign(value, 1, '%', showDiff);
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2016-06-06 13:07:20 +00:00
|
|
|
</script>
|
2019-01-04 12:18:43 +00:00
|
|
|
<script>
|
2021-03-17 10:07:14 +00:00
|
|
|
"use strict"
|
2016-05-11 12:32:27 +00:00
|
|
|
// =========================================================================
|
2016-05-06 13:23:51 +00:00
|
|
|
// EventHandlers
|
2021-03-02 13:56:46 +00:00
|
|
|
async function handleBodyLoad() {
|
2016-09-22 20:58:11 +00:00
|
|
|
$('uploadInput').focus();
|
2021-03-02 13:56:46 +00:00
|
|
|
if (tryLoadDefaultData() || await tryLoadFromURLParams() ||
|
2021-03-17 10:07:14 +00:00
|
|
|
await tryLoadDefaultResults()) {
|
2021-03-02 13:56:46 +00:00
|
|
|
displayResultsAfterLoading();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function tryLoadDefaultData() {
|
|
|
|
if (!defaultData) return false;
|
|
|
|
handleLoadJSON(defaultData);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function tryLoadFromURLParams() {
|
|
|
|
let params = new URLSearchParams(document.location.search);
|
|
|
|
let hasFile = false;
|
|
|
|
params.forEach(async (value, key) => {
|
|
|
|
if (key !== 'file') return;
|
|
|
|
hasFile ||= await tryLoadFile(value, true);
|
|
|
|
});
|
|
|
|
return hasFile;
|
2016-09-22 20:58:11 +00:00
|
|
|
}
|
|
|
|
|
2021-01-28 09:25:49 +00:00
|
|
|
async function tryLoadDefaultResults() {
|
2021-03-17 10:07:14 +00:00
|
|
|
if (window.location.protocol === 'file:') return false;
|
|
|
|
// Try to load a results.json file adjacent to this day.
|
|
|
|
// The markers on the following line can be used to replace the url easily
|
|
|
|
// with scripts.
|
|
|
|
const url = /*results-url-start*/ 'results.json' /*results-url-end*/;
|
|
|
|
return tryLoadFile(url);
|
2021-01-28 09:25:49 +00:00
|
|
|
}
|
|
|
|
|
2021-03-17 10:07:14 +00:00
|
|
|
async function tryLoadFile(url, append = false) {
|
2021-01-28 09:25:49 +00:00
|
|
|
if (!url.startsWith('http')) {
|
|
|
|
// hack to get relative urls
|
|
|
|
let location = window.location;
|
|
|
|
let parts = location.pathname.split("/").slice(0, -1);
|
|
|
|
url = location.origin + parts.join('/') + '/' + url;
|
|
|
|
}
|
|
|
|
let response = await fetch(url);
|
|
|
|
if (!response.ok) return false;
|
|
|
|
let filename = url.split('/');
|
2021-03-17 10:07:14 +00:00
|
|
|
filename = filename[filename.length - 1];
|
2021-01-28 09:25:49 +00:00
|
|
|
handleLoadText(await response.text(), append, filename);
|
2021-03-02 13:56:46 +00:00
|
|
|
return true;
|
2016-05-11 12:32:27 +00:00
|
|
|
}
|
|
|
|
|
2021-01-28 09:25:49 +00:00
|
|
|
function handleAppendFiles() {
|
2020-06-30 08:24:58 +00:00
|
|
|
let files = document.getElementById("appendInput").files;
|
2017-03-09 09:53:34 +00:00
|
|
|
loadFiles(files, true);
|
|
|
|
}
|
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
function handleLoadFiles() {
|
2020-06-30 08:24:58 +00:00
|
|
|
let files = document.getElementById("uploadInput").files;
|
2017-03-09 09:53:34 +00:00
|
|
|
loadFiles(files, false)
|
|
|
|
}
|
2017-04-10 17:45:35 +00:00
|
|
|
|
2021-01-28 09:25:49 +00:00
|
|
|
async function loadFiles(files, append) {
|
|
|
|
for (let i = 0; i < files.length; i++) {
|
|
|
|
const file = files[i];
|
|
|
|
console.log(file.name);
|
|
|
|
let text = await new Promise((resolve, reject) => {
|
|
|
|
const reader = new FileReader();
|
|
|
|
reader.onload = () => resolve(reader.result)
|
|
|
|
reader.readAsText(file);
|
|
|
|
});
|
|
|
|
handleLoadText(text, append, file.name);
|
2021-03-02 13:56:46 +00:00
|
|
|
// Only the first file might clear existing data, all sequent files
|
|
|
|
// are always append.
|
|
|
|
append = true;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2021-03-02 13:56:46 +00:00
|
|
|
displayResultsAfterLoading();
|
|
|
|
toggleCssClass(document.body, "loaded");
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
|
2020-02-19 16:42:44 +00:00
|
|
|
function handleLoadText(text, append, fileName) {
|
2021-02-10 09:41:45 +00:00
|
|
|
if (fileName.endsWith('.json')) {
|
|
|
|
handleLoadJSON(JSON.parse(text), append, fileName);
|
|
|
|
} else if (fileName.endsWith('.csv') ||
|
2021-03-17 10:07:14 +00:00
|
|
|
fileName.endsWith('.output') || fileName.endsWith('.output.txt')) {
|
2021-02-10 09:41:45 +00:00
|
|
|
handleLoadCSV(text, append, fileName);
|
|
|
|
} else if (fileName.endsWith('.txt')) {
|
|
|
|
handleLoadTXT(text, append, fileName);
|
|
|
|
} else {
|
2021-03-17 10:07:14 +00:00
|
|
|
alert(`Unsupported file extension: "${fileName}"`);
|
2020-04-28 10:38:25 +00:00
|
|
|
}
|
2016-09-29 13:31:12 +00:00
|
|
|
}
|
|
|
|
|
2016-11-22 10:12:53 +00:00
|
|
|
function getStateFromParams() {
|
2020-06-30 08:24:58 +00:00
|
|
|
let query = window.location.search.substr(1);
|
|
|
|
let result = {};
|
2016-11-22 10:12:53 +00:00
|
|
|
query.split("&").forEach((part) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let item = part.split("=");
|
|
|
|
let key = decodeURIComponent(item[0])
|
2016-11-22 10:12:53 +00:00
|
|
|
result[key] = decodeURIComponent(item[1]);
|
|
|
|
});
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-02-19 16:42:44 +00:00
|
|
|
function handleLoadJSON(json, append, fileName) {
|
2017-03-09 09:53:34 +00:00
|
|
|
json = fixClusterTelemetryResults(json);
|
2020-06-30 08:24:58 +00:00
|
|
|
json = fixTraceImportJSON(json);
|
|
|
|
json = fixSingleVersionJSON(json, fileName);
|
2021-02-08 11:37:32 +00:00
|
|
|
let isFirstLoad = pages === undefined;
|
2017-03-09 09:53:34 +00:00
|
|
|
if (append && !isFirstLoad) {
|
2021-03-17 10:07:14 +00:00
|
|
|
json = createUniqueVersions(json);
|
2017-03-09 09:53:34 +00:00
|
|
|
}
|
|
|
|
if (!append || isFirstLoad) {
|
|
|
|
pages = new Pages();
|
|
|
|
versions = Versions.fromJSON(json);
|
|
|
|
} else {
|
|
|
|
Versions.fromJSON(json).forEach(e => versions.add(e))
|
|
|
|
}
|
2020-04-28 10:38:25 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 11:37:32 +00:00
|
|
|
function handleLoadCSV(csv, append, fileName) {
|
|
|
|
let isFirstLoad = pages === undefined;
|
|
|
|
if (!append || isFirstLoad) {
|
|
|
|
pages = new Pages();
|
|
|
|
versions = new Versions();
|
|
|
|
}
|
|
|
|
const lines = csv.split(/\r?\n/);
|
|
|
|
// The first line contains only the field names.
|
|
|
|
const fields = new Map();
|
|
|
|
csvSplit(lines[0]).forEach((name, index) => {
|
|
|
|
fields.set(name, index);
|
|
|
|
});
|
|
|
|
if (fields.has('displayLabel') && fields.has('stories')) {
|
2021-03-17 10:07:14 +00:00
|
|
|
handleLoadResultCSV(fields, lines);
|
2021-02-08 11:37:32 +00:00
|
|
|
} else if (fields.has('page_name')) {
|
2021-03-17 10:07:14 +00:00
|
|
|
handleLoadClusterTelemetryCSV(fields, lines, fileName);
|
2021-02-08 11:37:32 +00:00
|
|
|
} else {
|
|
|
|
return alert("Unknown CSV format");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function csvSplit(line) {
|
|
|
|
let fields = [];
|
|
|
|
let index = 0;
|
|
|
|
while (index < line.length) {
|
|
|
|
let lastIndex = index;
|
|
|
|
if (line[lastIndex] == '"') {
|
2021-03-17 10:07:14 +00:00
|
|
|
index = line.indexOf('"', lastIndex + 1);
|
2021-02-08 11:37:32 +00:00
|
|
|
if (index < 0) index = line.length;
|
2021-03-17 10:07:14 +00:00
|
|
|
fields.push(line.substring(lastIndex + 1, index));
|
2021-02-08 11:37:32 +00:00
|
|
|
// Consume ','
|
|
|
|
index++;
|
|
|
|
} else {
|
|
|
|
index = line.indexOf(',', lastIndex);
|
|
|
|
if (index === -1) index = line.length;
|
|
|
|
fields.push(line.substring(lastIndex, index))
|
|
|
|
}
|
|
|
|
// Consume ','
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
return fields;
|
|
|
|
}
|
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
// Ignore the following categories as they are aggregated values and are
|
|
|
|
// created by callstats.html on the fly.
|
|
|
|
const import_skip_categories = new Set([
|
2021-03-17 10:07:14 +00:00
|
|
|
'V8-Only', 'V8-Only-Main-Thread', 'Total-Main-Thread', 'Blink_Total'
|
|
|
|
])
|
2021-03-02 13:56:46 +00:00
|
|
|
|
2021-02-08 11:37:32 +00:00
|
|
|
function handleLoadClusterTelemetryCSV(fields, lines, fileName) {
|
|
|
|
const rscFields = Array.from(fields.keys())
|
2021-03-02 13:56:46 +00:00
|
|
|
.filter(field => {
|
|
|
|
return field.endsWith(':duration (ms)') &&
|
|
|
|
!import_skip_categories.has(field.split(':')[0])
|
|
|
|
})
|
2021-02-08 11:37:32 +00:00
|
|
|
.map(field => {
|
|
|
|
let name = field.split(':')[0];
|
|
|
|
return [name, fields.get(field), fields.get(`${name}:count`)];
|
|
|
|
})
|
|
|
|
const page_name_i = fields.get('page_name');
|
|
|
|
const version = versions.getOrCreate(fileName);
|
2021-03-17 10:07:14 +00:00
|
|
|
for (let i = 1; i < lines.length; i++) {
|
2021-02-08 11:37:32 +00:00
|
|
|
const line = csvSplit(lines[i]);
|
2021-02-10 09:41:45 +00:00
|
|
|
if (line.length == 0) continue;
|
2021-02-08 11:37:32 +00:00
|
|
|
let page_name = line[page_name_i];
|
|
|
|
if (page_name === undefined) continue;
|
|
|
|
page_name = page_name.split(' ')[0];
|
|
|
|
const pageVersion = version.getOrCreate(page_name);
|
|
|
|
for (let [fieldName, duration_i, count_i] of rscFields) {
|
|
|
|
const duration = Number.parseFloat(line[duration_i]);
|
|
|
|
const count = Number.parseFloat(line[count_i]);
|
|
|
|
// Skip over entries without metrics (most likely crashes)
|
2021-03-17 10:07:14 +00:00
|
|
|
if (Number.isNaN(count) || Number.isNaN(duration)) {
|
2021-02-08 11:37:32 +00:00
|
|
|
console.warn(`BROKEN ${page_name}`, lines[i])
|
|
|
|
break;
|
|
|
|
}
|
2021-03-17 10:07:14 +00:00
|
|
|
pageVersion.add(new Entry(0, fieldName, duration, 0, 0, count, 0, 0))
|
2021-02-08 11:37:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-17 10:07:14 +00:00
|
|
|
function handleLoadResultCSV(fields, lines) {
|
2021-02-08 11:37:32 +00:00
|
|
|
const version_i = fields.get('displayLabel');
|
|
|
|
const page_i = fields.get('stories');
|
|
|
|
const category_i = fields.get('name');
|
|
|
|
const value_i = fields.get('avg');
|
|
|
|
const tempEntriesCache = new Map();
|
2021-03-17 10:07:14 +00:00
|
|
|
for (let i = 1; i < lines.length; i++) {
|
2021-02-08 11:37:32 +00:00
|
|
|
const line = csvSplit(lines[i]);
|
2021-02-10 09:41:45 +00:00
|
|
|
if (line.length == 0) continue;
|
2021-02-08 11:37:32 +00:00
|
|
|
const raw_category = line[category_i];
|
|
|
|
if (!raw_category.endsWith(':duration') &&
|
2021-03-17 10:07:14 +00:00
|
|
|
!raw_category.endsWith(':count')) {
|
2021-02-08 11:37:32 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
let [category, type] = raw_category.split(':');
|
2021-03-02 13:56:46 +00:00
|
|
|
if (import_skip_categories.has(category)) continue;
|
2021-02-08 11:37:32 +00:00
|
|
|
const version = versions.getOrCreate(line[version_i]);
|
|
|
|
const pageVersion = version.getOrCreate(line[page_i]);
|
|
|
|
const value = Number.parseFloat(line[value_i]);
|
|
|
|
const entry = TempEntry.get(tempEntriesCache, pageVersion, category);
|
|
|
|
if (type == 'duration') {
|
|
|
|
entry.durations.push(value)
|
|
|
|
} else {
|
|
|
|
entry.counts.push(value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tempEntriesCache.forEach((tempEntries, pageVersion) => {
|
|
|
|
tempEntries.forEach(tmpEntry => {
|
|
|
|
pageVersion.add(tmpEntry.toEntry())
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
class TempEntry {
|
|
|
|
constructor(category) {
|
|
|
|
this.category = category;
|
|
|
|
this.durations = [];
|
|
|
|
this.counts = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
static get(cache, pageVersion, category) {
|
|
|
|
let tempEntries = cache.get(pageVersion);
|
|
|
|
if (tempEntries === undefined) {
|
|
|
|
tempEntries = new Map();
|
|
|
|
cache.set(pageVersion, tempEntries);
|
|
|
|
}
|
2021-03-17 10:07:14 +00:00
|
|
|
let tempEntry = tempEntries.get(category);
|
2021-02-08 11:37:32 +00:00
|
|
|
if (tempEntry === undefined) {
|
|
|
|
tempEntry = new TempEntry(category);
|
|
|
|
tempEntries.set(category, tempEntry);
|
|
|
|
}
|
|
|
|
return tempEntry;
|
|
|
|
}
|
|
|
|
|
|
|
|
toEntry() {
|
|
|
|
const [duration, durationStddev] = this.stats(this.durations);
|
|
|
|
const [count, countStddev] = this.stats(this.durations);
|
|
|
|
return new Entry(0, this.category,
|
2021-03-17 10:07:14 +00:00
|
|
|
duration, durationStddev, 0, count, countStddev, 0)
|
2021-02-08 11:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stats(values) {
|
|
|
|
let sum = 0;
|
|
|
|
for (let i = 0; i < values.length; i++) {
|
|
|
|
sum += values[i];
|
|
|
|
}
|
|
|
|
const avg = sum / values.length;
|
|
|
|
let stddevSquared = 0;
|
|
|
|
for (let i = 0; i < values.length; i++) {
|
|
|
|
const delta = values[i] - avg;
|
|
|
|
stddevSquared += delta * delta;
|
|
|
|
}
|
|
|
|
const stddev = Math.sqrt(stddevSquared / values.length);
|
|
|
|
return [avg, stddev];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-28 10:38:25 +00:00
|
|
|
function handleLoadTXT(txt, append, fileName) {
|
2021-03-17 10:07:14 +00:00
|
|
|
fileName = window.prompt('Version name:', fileName);
|
2020-04-28 10:38:25 +00:00
|
|
|
let isFirstLoad = pages === undefined;
|
|
|
|
// Load raw RCS output which contains a single page
|
|
|
|
if (!append || isFirstLoad) {
|
|
|
|
pages = new Pages();
|
|
|
|
versions = new Versions()
|
|
|
|
}
|
2021-01-28 09:25:49 +00:00
|
|
|
versions.add(Version.fromTXT(fileName, txt));
|
2020-04-28 10:38:25 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
function displayResultsAfterLoading() {
|
|
|
|
const isFirstLoad = pages === undefined;
|
2020-04-28 10:38:25 +00:00
|
|
|
let state = getStateFromParams();
|
2017-03-09 09:53:34 +00:00
|
|
|
initialize()
|
2020-06-30 08:24:58 +00:00
|
|
|
if (isFirstLoad && !popHistoryState(state) && selectedPage) {
|
2017-03-09 09:53:34 +00:00
|
|
|
showEntry(selectedPage.total);
|
2020-04-28 10:38:25 +00:00
|
|
|
return;
|
2017-03-09 09:53:34 +00:00
|
|
|
}
|
2021-01-28 09:25:49 +00:00
|
|
|
const page = versions.versions[0].pages[0]
|
2021-03-17 10:07:14 +00:00
|
|
|
if (page == undefined) return;
|
2021-01-28 09:25:49 +00:00
|
|
|
showPage(page);
|
|
|
|
showEntry(page.total);
|
2017-03-09 09:53:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function fixClusterTelemetryResults(json) {
|
|
|
|
// Convert CT results to callstats compatible JSON
|
|
|
|
// Input:
|
2020-02-19 16:42:44 +00:00
|
|
|
// { VERSION_NAME: { PAGE: { METRIC: { "count": {XX}, "duration": {XX} }.. }}.. }
|
2017-03-09 09:53:34 +00:00
|
|
|
let firstEntry;
|
|
|
|
for (let key in json) {
|
|
|
|
firstEntry = json[key];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Return the original JSON if it is not a CT result.
|
|
|
|
if (firstEntry.pairs === undefined) return json;
|
|
|
|
// The results include already the group totals, remove them by filtering.
|
|
|
|
let groupNames = new Set(Array.from(Group.groups.values()).map(e => e.name));
|
|
|
|
let result = Object.create(null);
|
|
|
|
for (let file_name in json) {
|
|
|
|
let entries = [];
|
|
|
|
let file_data = json[file_name].pairs;
|
|
|
|
for (let name in file_data) {
|
2021-03-17 10:07:14 +00:00
|
|
|
if (name != "Total" && groupNames.has(name)) continue;
|
2017-03-09 09:53:34 +00:00
|
|
|
let entry = file_data[name];
|
|
|
|
let count = entry.count;
|
|
|
|
let time = entry.time;
|
|
|
|
entries.push([name, time, 0, 0, count, 0, 0]);
|
2021-02-08 11:37:32 +00:00
|
|
|
}
|
2017-03-09 09:53:34 +00:00
|
|
|
let domain = file_name.split("/").slice(-1)[0];
|
|
|
|
result[domain] = entries;
|
|
|
|
}
|
2021-03-17 10:07:14 +00:00
|
|
|
return {
|
|
|
|
__proto__: null,
|
|
|
|
ClusterTelemetry: result
|
|
|
|
};
|
2017-03-09 09:53:34 +00:00
|
|
|
}
|
|
|
|
|
2020-06-30 08:24:58 +00:00
|
|
|
function fixTraceImportJSON(json) {
|
|
|
|
// Fix json file that was created by converting a trace json output
|
|
|
|
if (!('telemetry-results' in json)) return json;
|
|
|
|
// { telemetry-results: { PAGE:[ { METRIC: [ COUNT TIME ], ... }, ... ]}}
|
2021-03-17 10:07:14 +00:00
|
|
|
let version_data = {
|
|
|
|
__proto__: null
|
|
|
|
};
|
2020-06-30 08:24:58 +00:00
|
|
|
json = json["telemetry-results"];
|
|
|
|
for (let page_name in json) {
|
|
|
|
if (page_name == "placeholder") continue;
|
|
|
|
let page_data = {
|
2021-03-17 10:07:14 +00:00
|
|
|
__proto__: null,
|
|
|
|
Total: {
|
|
|
|
duration: {
|
|
|
|
average: 0,
|
|
|
|
stddev: 0
|
|
|
|
},
|
|
|
|
count: {
|
|
|
|
average: 0,
|
|
|
|
stddev: 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2020-06-30 08:24:58 +00:00
|
|
|
let page = json[page_name];
|
2021-03-17 10:07:14 +00:00
|
|
|
for (let slice of page) {
|
2020-06-30 08:24:58 +00:00
|
|
|
for (let metric_name in slice) {
|
|
|
|
if (metric_name == "Blink_V8") continue;
|
|
|
|
// sum up entries
|
|
|
|
if (!(metric_name in page_data)) {
|
|
|
|
page_data[metric_name] = {
|
2021-03-17 10:07:14 +00:00
|
|
|
duration: {
|
|
|
|
average: 0,
|
|
|
|
stddev: 0
|
|
|
|
},
|
|
|
|
count: {
|
|
|
|
average: 0,
|
|
|
|
stddev: 0
|
|
|
|
}
|
2020-06-30 08:24:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
let [metric_count, metric_duration] = slice[metric_name]
|
|
|
|
let metric = page_data[metric_name];
|
2021-03-17 10:07:14 +00:00
|
|
|
const kMicroToMilli = 1 / 1000;
|
2020-06-30 08:24:58 +00:00
|
|
|
metric.duration.average += metric_duration * kMicroToMilli;
|
|
|
|
metric.count.average += metric_count;
|
|
|
|
|
|
|
|
if (metric_name.startsWith('Blink_')) continue;
|
|
|
|
let total = page_data['Total'];
|
|
|
|
total.duration.average += metric_duration * kMicroToMilli;
|
|
|
|
total.count.average += metric_count;
|
2021-02-08 11:37:32 +00:00
|
|
|
}
|
2020-06-30 08:24:58 +00:00
|
|
|
}
|
|
|
|
version_data[page_name] = page_data;
|
|
|
|
}
|
|
|
|
return version_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
function fixSingleVersionJSON(json, name) {
|
2016-12-08 11:35:06 +00:00
|
|
|
// Try to detect the single-version case, where we're missing the toplevel
|
|
|
|
// version object. The incoming JSON is of the form:
|
2021-03-17 10:07:14 +00:00
|
|
|
// { PAGE: ... , PAGE_2: }
|
2016-12-08 11:35:06 +00:00
|
|
|
// Instead of the default multi-page JSON:
|
|
|
|
// {"Version 1": { "Page 1": ..., ...}, "Version 2": {...}, ...}
|
|
|
|
// In this case insert a single "Default" version as top-level entry.
|
2020-02-19 16:42:44 +00:00
|
|
|
let firstProperty = (object) => {
|
|
|
|
for (let key in object) return object[key];
|
2016-12-08 11:35:06 +00:00
|
|
|
};
|
2020-02-19 16:42:44 +00:00
|
|
|
let maybePage = firstProperty(json);
|
|
|
|
let maybeMetrics = firstProperty(maybePage);
|
|
|
|
let tempName = name ? name : new Date().toISOString();
|
2020-06-30 08:24:58 +00:00
|
|
|
tempName = window.prompt('Enter a name for the loaded file:', tempName);
|
2020-02-19 16:42:44 +00:00
|
|
|
if ('count' in maybeMetrics && 'duration' in maybeMetrics) {
|
2021-03-17 10:07:14 +00:00
|
|
|
return {
|
|
|
|
[tempName]: json
|
|
|
|
}
|
2020-02-19 16:42:44 +00:00
|
|
|
}
|
|
|
|
// Legacy fallback where the metrics are encoded as arrays:
|
|
|
|
// { PAGE: [[metric_name, ...], [...], ]}
|
|
|
|
if (Array.isArray(maybeMetrics)) {
|
2021-03-17 10:07:14 +00:00
|
|
|
return {
|
|
|
|
[tempName]: json
|
|
|
|
}
|
2020-02-19 16:42:44 +00:00
|
|
|
}
|
|
|
|
return json
|
2016-12-08 11:35:06 +00:00
|
|
|
}
|
|
|
|
|
2020-06-30 08:24:58 +00:00
|
|
|
let appendIndex = 0;
|
2021-03-17 10:07:14 +00:00
|
|
|
|
2017-03-09 09:53:34 +00:00
|
|
|
function createUniqueVersions(json) {
|
2020-06-30 08:24:58 +00:00
|
|
|
// Make sure all toplevel entries are unique names and added properly
|
2017-03-09 09:53:34 +00:00
|
|
|
appendIndex++;
|
2021-03-17 10:07:14 +00:00
|
|
|
let result = {
|
|
|
|
__proto__: null
|
|
|
|
}
|
2017-03-09 09:53:34 +00:00
|
|
|
for (let key in json) {
|
2021-03-17 10:07:14 +00:00
|
|
|
result[key + "_" + appendIndex] = json[key];
|
2016-11-22 10:12:53 +00:00
|
|
|
}
|
2017-03-09 09:53:34 +00:00
|
|
|
return result
|
2016-09-22 20:58:11 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 11:37:32 +00:00
|
|
|
function handleCopyToClipboard(event) {
|
2021-03-17 10:07:14 +00:00
|
|
|
const names = ["Group", ...versions.versions.map(e => e.name)];
|
|
|
|
let result = [names.join("\t")];
|
2021-01-28 09:25:49 +00:00
|
|
|
let groups = Array.from(Group.groups.values());
|
|
|
|
// Move the total group to the end.
|
|
|
|
groups.push(groups.shift())
|
|
|
|
groups.forEach(group => {
|
|
|
|
let row = [group.name];
|
|
|
|
versions.forEach(v => {
|
2021-03-17 10:07:14 +00:00
|
|
|
const time = v.pages[0].get("Group-" + group.name)?._time ?? 0;
|
|
|
|
row.push(time);
|
2021-01-28 09:25:49 +00:00
|
|
|
})
|
|
|
|
result.push(row.join("\t"));
|
|
|
|
});
|
|
|
|
result = result.join("\n");
|
2021-03-17 10:07:14 +00:00
|
|
|
navigator.clipboard.writeText(result);
|
2021-01-28 09:25:49 +00:00
|
|
|
}
|
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
function handleToggleGroup(event) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let group = event.target.parentNode.parentNode.entry;
|
2021-03-17 10:07:14 +00:00
|
|
|
toggleGroup(selectedPage.get(group.name), 'toggle');
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function handleSelectPage(select, event) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let option = select.options[select.selectedIndex];
|
2016-05-06 13:23:51 +00:00
|
|
|
if (select.id == "select_0") {
|
2017-03-01 13:28:06 +00:00
|
|
|
showSelectedEntryInPage(option.page);
|
2016-05-06 13:23:51 +00:00
|
|
|
} else {
|
2020-06-30 08:24:58 +00:00
|
|
|
let columnIndex = select.id.split('_')[1];
|
2016-05-06 13:23:51 +00:00
|
|
|
showPageInColumn(option.page, columnIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleSelectVersion(select, event) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let option = select.options[select.selectedIndex];
|
|
|
|
let version = option.version;
|
2016-05-06 13:23:51 +00:00
|
|
|
if (select.id == "selectVersion_0") {
|
2020-06-30 08:24:58 +00:00
|
|
|
let page = version.get(selectedPage.name);
|
2017-03-01 13:28:06 +00:00
|
|
|
showSelectedEntryInPage(page);
|
2016-05-06 13:23:51 +00:00
|
|
|
} else {
|
2020-06-30 08:24:58 +00:00
|
|
|
let columnIndex = select.id.split('_')[1];
|
|
|
|
let pageSelect = $('select_' + columnIndex);
|
|
|
|
let page = pageSelect.options[pageSelect.selectedIndex].page;
|
2016-05-06 13:23:51 +00:00
|
|
|
page = version.get(page.name);
|
|
|
|
showPageInColumn(page, columnIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleSelectDetailRow(table, event) {
|
|
|
|
if (event.target.tagName != 'TD') return;
|
2020-06-30 08:24:58 +00:00
|
|
|
let tr = event.target.parentNode;
|
2016-05-06 13:23:51 +00:00
|
|
|
if (tr.tagName != 'TR') return;
|
|
|
|
if (tr.entry === undefined) return;
|
|
|
|
selectEntry(tr.entry, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleSelectRow(table, event, fromDetail) {
|
|
|
|
if (event.target.tagName != 'TD') return;
|
2020-06-30 08:24:58 +00:00
|
|
|
let tr = event.target.parentNode;
|
2016-05-06 13:23:51 +00:00
|
|
|
if (tr.tagName != 'TR') return;
|
|
|
|
if (tr.entry === undefined) return;
|
|
|
|
selectEntry(tr.entry, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleSelectBaseline(select, event) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let option = select.options[select.selectedIndex];
|
2016-06-06 13:07:20 +00:00
|
|
|
baselineVersion = option.version;
|
2020-06-30 08:24:58 +00:00
|
|
|
let showingDiff = baselineVersion !== undefined;
|
|
|
|
let body = $('body');
|
2016-06-06 13:07:20 +00:00
|
|
|
toggleCssClass(body, 'diff', showingDiff);
|
|
|
|
toggleCssClass(body, 'noDiff', !showingDiff);
|
2016-05-06 13:23:51 +00:00
|
|
|
showPage(selectedPage);
|
|
|
|
if (selectedEntry === undefined) return;
|
|
|
|
selectEntry(selectedEntry, true);
|
|
|
|
}
|
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
function findEntry(event) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let target = event.target;
|
2016-06-06 13:07:20 +00:00
|
|
|
while (target.entry === undefined) {
|
|
|
|
target = target.parentNode;
|
|
|
|
if (!target) return undefined;
|
|
|
|
}
|
|
|
|
return target.entry;
|
|
|
|
}
|
|
|
|
|
2016-05-06 13:23:51 +00:00
|
|
|
function handleUpdatePopover(event) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let popover = $('popover');
|
2016-05-06 13:23:51 +00:00
|
|
|
popover.style.left = event.pageX + 'px';
|
|
|
|
popover.style.top = event.pageY + 'px';
|
2016-06-06 13:07:20 +00:00
|
|
|
popover.style.display = 'none';
|
2016-05-06 13:23:51 +00:00
|
|
|
popover.style.display = event.shiftKey ? 'block' : 'none';
|
2020-06-30 08:24:58 +00:00
|
|
|
let entry = findEntry(event);
|
2016-06-06 13:07:20 +00:00
|
|
|
if (entry === undefined) return;
|
|
|
|
showPopover(entry);
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
|
2016-09-28 07:49:45 +00:00
|
|
|
function handleToggleVersionOrPageEnable(event) {
|
2021-03-17 10:07:14 +00:00
|
|
|
let item = this.item;
|
|
|
|
if (item === undefined) return;
|
|
|
|
item.enabled = this.checked;
|
2016-05-11 12:32:27 +00:00
|
|
|
initialize();
|
2020-06-30 08:24:58 +00:00
|
|
|
let page = selectedPage;
|
2016-05-11 12:32:27 +00:00
|
|
|
if (page === undefined || !page.version.enabled) {
|
|
|
|
page = versions.getEnabledPage(page.name);
|
|
|
|
}
|
2016-09-28 07:49:45 +00:00
|
|
|
if (!page.enabled) {
|
|
|
|
page = page.getNextPage();
|
|
|
|
}
|
2016-05-11 12:32:27 +00:00
|
|
|
showPage(page);
|
|
|
|
}
|
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
function handleCodeSearch(event) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let entry = findEntry(event);
|
2016-06-06 13:07:20 +00:00
|
|
|
if (entry === undefined) return;
|
2020-06-30 08:24:58 +00:00
|
|
|
let url = "https://cs.chromium.org/search/?sq=package:chromium&type=cs&q=";
|
2016-06-06 13:07:20 +00:00
|
|
|
name = entry.name;
|
|
|
|
if (name.startsWith("API_")) {
|
|
|
|
name = name.substring(4);
|
|
|
|
}
|
|
|
|
url += encodeURIComponent(name) + "+file:src/v8/src";
|
2021-03-17 10:07:14 +00:00
|
|
|
window.open(url, '_blank');
|
2016-06-06 13:07:20 +00:00
|
|
|
}
|
|
|
|
</script>
|
2019-01-04 12:18:43 +00:00
|
|
|
<script>
|
2021-03-17 10:07:14 +00:00
|
|
|
"use strict"
|
2016-06-06 13:07:20 +00:00
|
|
|
// =========================================================================
|
2016-05-06 13:23:51 +00:00
|
|
|
class Versions {
|
|
|
|
constructor() {
|
|
|
|
this.versions = [];
|
|
|
|
}
|
|
|
|
add(version) {
|
2021-02-08 11:37:32 +00:00
|
|
|
this.versions.push(version);
|
|
|
|
return version;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2016-06-06 13:07:20 +00:00
|
|
|
getPageVersions(page) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let result = [];
|
2016-05-06 13:23:51 +00:00
|
|
|
this.versions.forEach((version) => {
|
2016-05-11 12:32:27 +00:00
|
|
|
if (!version.enabled) return;
|
2020-06-30 08:24:58 +00:00
|
|
|
let versionPage = version.get(page.name);
|
2021-03-17 10:07:14 +00:00
|
|
|
if (versionPage !== undefined) result.push(versionPage);
|
2016-05-06 13:23:51 +00:00
|
|
|
});
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
get length() {
|
|
|
|
return this.versions.length
|
|
|
|
}
|
|
|
|
get(index) {
|
|
|
|
return this.versions[index]
|
2016-11-22 10:12:53 +00:00
|
|
|
}
|
|
|
|
getByName(name) {
|
|
|
|
return this.versions.find((each) => each.name == name);
|
|
|
|
}
|
2021-02-08 11:37:32 +00:00
|
|
|
getOrCreate(name) {
|
2021-03-17 10:07:14 +00:00
|
|
|
return this.getByName(name) ?? this.add(new Version(name));
|
2021-02-08 11:37:32 +00:00
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
forEach(f) {
|
|
|
|
this.versions.forEach(f);
|
|
|
|
}
|
|
|
|
sort() {
|
2016-06-06 13:07:20 +00:00
|
|
|
this.versions.sort(NameComparator);
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2016-05-11 12:32:27 +00:00
|
|
|
getEnabledPage(name) {
|
2020-06-30 08:24:58 +00:00
|
|
|
for (let i = 0; i < this.versions.length; i++) {
|
|
|
|
let version = this.versions[i];
|
2016-05-11 12:32:27 +00:00
|
|
|
if (!version.enabled) continue;
|
2020-06-30 08:24:58 +00:00
|
|
|
let page = version.get(name);
|
2016-05-11 12:32:27 +00:00
|
|
|
if (page !== undefined) return page;
|
2016-06-06 13:07:20 +00:00
|
|
|
}
|
2016-05-11 12:32:27 +00:00
|
|
|
}
|
2020-04-28 10:38:25 +00:00
|
|
|
|
|
|
|
static fromJSON(json) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let versions = new Versions();
|
|
|
|
for (let version in json) {
|
2020-04-28 10:38:25 +00:00
|
|
|
versions.add(Version.fromJSON(version, json[version]));
|
|
|
|
}
|
|
|
|
versions.sort();
|
|
|
|
return versions;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Version {
|
|
|
|
constructor(name) {
|
|
|
|
this.name = name;
|
2016-05-11 12:32:27 +00:00
|
|
|
this.enabled = true;
|
|
|
|
this.pages = [];
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
add(page) {
|
|
|
|
this.pages.push(page);
|
2021-02-08 11:37:32 +00:00
|
|
|
return page;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
indexOf(name) {
|
2020-06-30 08:24:58 +00:00
|
|
|
for (let i = 0; i < this.pages.length; i++) {
|
2016-05-06 13:23:51 +00:00
|
|
|
if (this.pages[i].name == name) return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2016-09-28 07:49:45 +00:00
|
|
|
getNextPage(page) {
|
|
|
|
if (this.length == 0) return undefined;
|
|
|
|
return this.pages[(this.indexOf(page.name) + 1) % this.length];
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
get(name) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let index = this.indexOf(name);
|
2016-05-06 13:23:51 +00:00
|
|
|
if (0 <= index) return this.pages[index];
|
2021-03-17 10:07:14 +00:00
|
|
|
return undefined;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2021-02-08 11:37:32 +00:00
|
|
|
getOrCreate(name) {
|
|
|
|
return this.get(name) ??
|
|
|
|
this.add(new PageVersion(this, pages.getOrCreate(name)));
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
get length() {
|
2021-03-17 10:07:14 +00:00
|
|
|
return this.pages.length;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
getEntry(entry) {
|
|
|
|
if (entry === undefined) return undefined;
|
2020-06-30 08:24:58 +00:00
|
|
|
let page = this.get(entry.page.name);
|
2016-05-06 13:23:51 +00:00
|
|
|
if (page === undefined) return undefined;
|
|
|
|
return page.get(entry.name);
|
|
|
|
}
|
|
|
|
forEachEntry(fun) {
|
2016-06-06 13:07:20 +00:00
|
|
|
this.forEachPage((page) => {
|
2016-05-06 13:23:51 +00:00
|
|
|
page.forEach(fun);
|
|
|
|
});
|
|
|
|
}
|
2016-06-06 13:07:20 +00:00
|
|
|
forEachPage(fun) {
|
|
|
|
this.pages.forEach((page) => {
|
|
|
|
if (!page.enabled) return;
|
|
|
|
fun(page);
|
|
|
|
})
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
allEntries() {
|
2020-06-30 08:24:58 +00:00
|
|
|
let map = new Map();
|
2016-05-06 13:23:51 +00:00
|
|
|
this.forEachEntry((group, entry) => {
|
|
|
|
if (!map.has(entry.name)) map.set(entry.name, entry);
|
|
|
|
});
|
|
|
|
return Array.from(map.values());
|
|
|
|
}
|
|
|
|
getTotalValue(name, property) {
|
|
|
|
if (name === undefined) name = this.pages[0].total.name;
|
2020-06-30 08:24:58 +00:00
|
|
|
let sum = 0;
|
2016-06-06 13:07:20 +00:00
|
|
|
this.forEachPage((page) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let entry = page.get(name);
|
2016-05-06 13:23:51 +00:00
|
|
|
if (entry !== undefined) sum += entry[property];
|
|
|
|
});
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
getTotalTime(name, showDiff) {
|
|
|
|
return this.getTotalValue(name, showDiff === false ? '_time' : 'time');
|
|
|
|
}
|
|
|
|
getTotalTimePercent(name, showDiff) {
|
2016-06-06 13:07:20 +00:00
|
|
|
if (baselineVersion === undefined || showDiff === false) {
|
2016-05-11 12:32:27 +00:00
|
|
|
// Return the overall average percent of the given entry name.
|
|
|
|
return this.getTotalValue(name, 'time') /
|
|
|
|
this.getTotalTime('Group-Total') * 100;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2016-05-11 12:32:27 +00:00
|
|
|
// Otherwise return the difference to the sum of the baseline version.
|
2020-06-30 08:24:58 +00:00
|
|
|
let baselineValue = baselineVersion.getTotalTime(name, false);
|
|
|
|
let total = this.getTotalValue(name, '_time');
|
2021-03-17 10:07:14 +00:00
|
|
|
return (total / baselineValue - 1) * 100;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
getTotalTimeVariance(name, showDiff) {
|
|
|
|
// Calculate the overall error for a given entry name
|
2020-06-30 08:24:58 +00:00
|
|
|
let sum = 0;
|
2016-06-06 13:07:20 +00:00
|
|
|
this.forEachPage((page) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let entry = page.get(name);
|
2016-05-06 13:23:51 +00:00
|
|
|
if (entry === undefined) return;
|
|
|
|
sum += entry.timeVariance * entry.timeVariance;
|
|
|
|
});
|
|
|
|
return Math.sqrt(sum);
|
|
|
|
}
|
|
|
|
getTotalTimeVariancePercent(name, showDiff) {
|
2017-02-08 17:29:56 +00:00
|
|
|
return this.getTotalTimeVariance(name, showDiff) /
|
2016-05-06 13:23:51 +00:00
|
|
|
this.getTotalTime(name, showDiff) * 100;
|
|
|
|
}
|
|
|
|
getTotalCount(name, showDiff) {
|
2016-05-11 12:32:27 +00:00
|
|
|
return this.getTotalValue(name, showDiff === false ? '_count' : 'count');
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2016-06-06 13:07:20 +00:00
|
|
|
getAverageTimeImpact(name, showDiff) {
|
|
|
|
return this.getTotalTime(name, showDiff) / this.pages.length;
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
getPagesByPercentImpact(name) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let sortedPages =
|
2016-05-06 13:23:51 +00:00
|
|
|
this.pages.filter((each) => {
|
|
|
|
return each.get(name) !== undefined
|
|
|
|
});
|
|
|
|
sortedPages.sort((a, b) => {
|
|
|
|
return b.get(name).timePercent - a.get(name).timePercent;
|
|
|
|
});
|
|
|
|
return sortedPages;
|
|
|
|
}
|
2016-05-11 12:32:27 +00:00
|
|
|
sort() {
|
2016-06-06 13:07:20 +00:00
|
|
|
this.pages.sort(NameComparator)
|
2016-05-11 12:32:27 +00:00
|
|
|
}
|
2020-04-28 10:38:25 +00:00
|
|
|
|
|
|
|
static fromJSON(name, data) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let version = new Version(name);
|
|
|
|
for (let pageName in data) {
|
2020-04-28 10:38:25 +00:00
|
|
|
version.add(PageVersion.fromJSON(version, pageName, data[pageName]));
|
|
|
|
}
|
|
|
|
version.sort();
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
|
|
|
static fromTXT(name, txt) {
|
|
|
|
let version = new Version(name);
|
2021-03-17 10:07:14 +00:00
|
|
|
let defaultName = "RAW DATA";
|
|
|
|
PageVersion.fromTXT(version, defaultName, txt)
|
|
|
|
.forEach(each => version.add(each));
|
2020-04-28 10:38:25 +00:00
|
|
|
return version;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
class Pages extends Map {
|
|
|
|
get(name) {
|
|
|
|
if (name.indexOf('www.') == 0) {
|
|
|
|
name = name.substring(4);
|
|
|
|
}
|
|
|
|
if (!this.has(name)) {
|
|
|
|
this.set(name, new Page(name));
|
|
|
|
}
|
|
|
|
return super.get(name);
|
|
|
|
}
|
2021-02-08 11:37:32 +00:00
|
|
|
getOrCreate(name) {
|
|
|
|
return this.get(name);
|
|
|
|
}
|
2016-06-06 13:07:20 +00:00
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
|
|
|
|
class Page {
|
2016-06-06 13:07:20 +00:00
|
|
|
constructor(name) {
|
2016-05-06 13:23:51 +00:00
|
|
|
this.name = name;
|
2016-06-06 13:07:20 +00:00
|
|
|
this.enabled = true;
|
|
|
|
this.versions = [];
|
|
|
|
}
|
2021-02-08 11:37:32 +00:00
|
|
|
add(pageVersion) {
|
|
|
|
this.versions.push(pageVersion);
|
|
|
|
return pageVersion;
|
2016-06-06 13:07:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class PageVersion {
|
|
|
|
constructor(version, page) {
|
|
|
|
this.page = page;
|
|
|
|
this.page.add(this);
|
2016-09-28 07:49:45 +00:00
|
|
|
this.total = Group.groups.get('total').entry();
|
2016-06-06 13:07:20 +00:00
|
|
|
this.total.isTotal = true;
|
2016-09-28 07:49:45 +00:00
|
|
|
this.unclassified = new UnclassifiedEntry(this)
|
2016-05-06 13:23:51 +00:00
|
|
|
this.groups = [
|
|
|
|
this.total,
|
2016-09-28 07:49:45 +00:00
|
|
|
Group.groups.get('ic').entry(),
|
2018-09-06 14:23:36 +00:00
|
|
|
Group.groups.get('optimize-background').entry(),
|
2016-09-28 07:49:45 +00:00
|
|
|
Group.groups.get('optimize').entry(),
|
2017-01-03 18:11:58 +00:00
|
|
|
Group.groups.get('compile-background').entry(),
|
2016-09-28 07:49:45 +00:00
|
|
|
Group.groups.get('compile').entry(),
|
2016-11-16 18:51:32 +00:00
|
|
|
Group.groups.get('parse-background').entry(),
|
2016-09-28 07:49:45 +00:00
|
|
|
Group.groups.get('parse').entry(),
|
2020-06-30 08:24:58 +00:00
|
|
|
Group.groups.get('blink').entry(),
|
2016-09-28 07:49:45 +00:00
|
|
|
Group.groups.get('callback').entry(),
|
|
|
|
Group.groups.get('api').entry(),
|
2021-02-08 11:37:32 +00:00
|
|
|
Group.groups.get('gc-custom').entry(),
|
|
|
|
Group.groups.get('gc-background').entry(),
|
2016-09-28 07:49:45 +00:00
|
|
|
Group.groups.get('gc').entry(),
|
|
|
|
Group.groups.get('javascript').entry(),
|
|
|
|
Group.groups.get('runtime').entry(),
|
2016-05-06 13:23:51 +00:00
|
|
|
this.unclassified
|
|
|
|
];
|
|
|
|
this.entryDict = new Map();
|
|
|
|
this.groups.forEach((entry) => {
|
|
|
|
entry.page = this;
|
|
|
|
this.entryDict.set(entry.name, entry);
|
|
|
|
});
|
|
|
|
this.version = version;
|
|
|
|
}
|
2016-11-22 10:12:53 +00:00
|
|
|
toString() {
|
|
|
|
return this.version.name + ": " + this.name;
|
|
|
|
}
|
|
|
|
urlParams() {
|
2021-03-17 10:07:14 +00:00
|
|
|
return {
|
|
|
|
version: this.version.name,
|
|
|
|
page: this.name
|
|
|
|
};
|
2016-11-22 10:12:53 +00:00
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
add(entry) {
|
2021-01-28 09:25:49 +00:00
|
|
|
let existingEntry = this.entryDict.get(entry.name);
|
|
|
|
if (existingEntry !== undefined) {
|
2021-02-08 11:37:32 +00:00
|
|
|
// Duplicate entries happen when multiple runs are combined into a
|
2021-01-28 09:25:49 +00:00
|
|
|
// single file.
|
|
|
|
existingEntry.add(entry);
|
2021-03-17 10:07:14 +00:00
|
|
|
for (let i = 0; i < this.groups.length; i++) {
|
|
|
|
const group = this.groups[i];
|
2021-01-28 09:25:49 +00:00
|
|
|
if (group.addTimeAndCount(entry)) return;
|
|
|
|
}
|
|
|
|
} else {
|
2021-03-17 10:07:14 +00:00
|
|
|
// Ignore accidentally added Group entries.
|
|
|
|
if (entry.name.startsWith(GroupedEntry.prefix)) {
|
|
|
|
console.warn("Skipping accidentally added Group entry:", entry, this);
|
|
|
|
return;
|
|
|
|
}
|
2021-01-28 09:25:49 +00:00
|
|
|
entry.page = this;
|
|
|
|
this.entryDict.set(entry.name, entry);
|
2021-02-08 11:37:32 +00:00
|
|
|
for (let group of this.groups) {
|
2021-01-28 09:25:49 +00:00
|
|
|
if (group.add(entry)) return;
|
|
|
|
}
|
2020-06-30 08:24:58 +00:00
|
|
|
}
|
2021-01-28 09:25:49 +00:00
|
|
|
console.error("Should not get here", entry);
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
get(name) {
|
|
|
|
return this.entryDict.get(name)
|
|
|
|
}
|
|
|
|
getEntry(entry) {
|
|
|
|
if (entry === undefined) return undefined;
|
|
|
|
return this.get(entry.name);
|
|
|
|
}
|
|
|
|
get length() {
|
|
|
|
return this.versions.length
|
|
|
|
}
|
2021-03-17 10:07:14 +00:00
|
|
|
get name() {
|
|
|
|
return this.page.name
|
|
|
|
}
|
|
|
|
get enabled() {
|
|
|
|
return this.page.enabled
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
forEachSorted(referencePage, func) {
|
2016-06-06 13:07:20 +00:00
|
|
|
// Iterate over all the entries in the order they appear on the
|
|
|
|
// reference page.
|
2016-05-06 13:23:51 +00:00
|
|
|
referencePage.forEach((parent, referenceEntry) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
let entry;
|
2016-05-06 13:23:51 +00:00
|
|
|
if (parent) parent = this.entryDict.get(parent.name);
|
|
|
|
if (referenceEntry) entry = this.entryDict.get(referenceEntry.name);
|
|
|
|
func(parent, entry, referenceEntry);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
forEach(fun) {
|
|
|
|
this.forEachGroup((group) => {
|
|
|
|
fun(undefined, group);
|
|
|
|
group.forEach((entry) => {
|
|
|
|
fun(group, entry)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
forEachGroup(fun) {
|
|
|
|
this.groups.forEach(fun)
|
|
|
|
}
|
|
|
|
sort() {
|
|
|
|
this.groups.sort((a, b) => {
|
|
|
|
return b.time - a.time;
|
|
|
|
});
|
|
|
|
this.groups.forEach((group) => {
|
|
|
|
group.sort()
|
|
|
|
});
|
|
|
|
}
|
2016-06-06 13:07:20 +00:00
|
|
|
distanceFromTotalPercent() {
|
2020-06-30 08:24:58 +00:00
|
|
|
let sum = 0;
|
2016-06-06 13:07:20 +00:00
|
|
|
this.groups.forEach(group => {
|
|
|
|
if (group == this.total) return;
|
2020-06-30 08:24:58 +00:00
|
|
|
let value = group.getTimePercentImpact() -
|
2021-03-17 10:07:14 +00:00
|
|
|
this.getEntry(group).timePercent;
|
2016-06-06 13:07:20 +00:00
|
|
|
sum += value * value;
|
|
|
|
});
|
|
|
|
return sum;
|
2016-05-11 12:32:27 +00:00
|
|
|
}
|
2016-09-28 07:49:45 +00:00
|
|
|
getNextPage() {
|
|
|
|
return this.version.getNextPage(this);
|
|
|
|
}
|
2020-04-28 10:38:25 +00:00
|
|
|
|
|
|
|
static fromJSON(version, name, data) {
|
|
|
|
let page = new PageVersion(version, pages.get(name));
|
|
|
|
// Distinguish between the legacy format which just uses Arrays,
|
|
|
|
// or the new object style.
|
|
|
|
if (Array.isArray(data)) {
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
|
page.add(Entry.fromLegacyJSON(i, data[data.length - i - 1]));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
let position = 0;
|
|
|
|
for (let metric_name in data) {
|
|
|
|
page.add(Entry.fromJSON(position, metric_name, data[metric_name]));
|
|
|
|
position++;
|
|
|
|
}
|
2020-02-19 16:42:44 +00:00
|
|
|
}
|
2020-04-28 10:38:25 +00:00
|
|
|
page.sort();
|
|
|
|
return page
|
|
|
|
}
|
|
|
|
|
2021-03-17 10:07:14 +00:00
|
|
|
static fromTXT(version, defaultName, txt) {
|
|
|
|
const kPageNameIdentifier = "== Page:";
|
|
|
|
const kCommentStart = "=="
|
|
|
|
const lines = txt.split('\n');
|
|
|
|
const split = / +/g
|
|
|
|
const result = [];
|
|
|
|
let pageVersion = undefined;
|
|
|
|
for (let i = 0; i < lines.length; i++) {
|
|
|
|
const line = lines[i];
|
|
|
|
// Skip header separators
|
|
|
|
if (line.startsWith(kCommentStart)) {
|
|
|
|
// Check for page names
|
|
|
|
if (line.startsWith(kPageNameIdentifier)) {
|
|
|
|
const name = line.split(kPageNameIdentifier)[1];
|
|
|
|
pageVersion = new PageVersion(version, pages.get(name));
|
|
|
|
result.push(pageVersion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Skip header lines.
|
|
|
|
if (lines[i + 1]?.startsWith(kCommentStart)) continue;
|
|
|
|
const split_line = line.trim().split(split)
|
|
|
|
if (split_line.length != 5) continue;
|
|
|
|
if (pageVersion === undefined) {
|
|
|
|
pageVersion = new PageVersion(version, pages.get(defaultName));
|
|
|
|
result.push(pageVersion);
|
|
|
|
}
|
|
|
|
const position = i - 2;
|
|
|
|
pageVersion.add(Entry.fromTXT(position, split_line));
|
2020-02-19 16:42:44 +00:00
|
|
|
}
|
2021-03-17 10:07:14 +00:00
|
|
|
return result;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class Entry {
|
|
|
|
constructor(position, name, time, timeVariance, timeVariancePercent,
|
2021-03-17 10:07:14 +00:00
|
|
|
count, countVariance, countVariancePercent) {
|
2016-05-06 13:23:51 +00:00
|
|
|
this.position = position;
|
|
|
|
this.name = name;
|
|
|
|
this._time = time;
|
|
|
|
this._timeVariance = timeVariance;
|
2021-02-08 11:37:32 +00:00
|
|
|
this._timeVariancePercent =
|
|
|
|
this._variancePercent(time, timeVariance, timeVariancePercent);
|
2016-05-06 13:23:51 +00:00
|
|
|
this._count = count;
|
|
|
|
this.countVariance = countVariance;
|
2021-02-08 11:37:32 +00:00
|
|
|
this.countVariancePercent =
|
|
|
|
this._variancePercent(count, countVariance, countVariancePercent);
|
2016-05-06 13:23:51 +00:00
|
|
|
this.page = undefined;
|
|
|
|
this.parent = undefined;
|
2016-06-06 13:07:20 +00:00
|
|
|
this.isTotal = false;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2021-02-08 11:37:32 +00:00
|
|
|
_variancePercent(value, valueVariance, valueVariancePercent) {
|
|
|
|
if (valueVariancePercent) return valueVariancePercent;
|
|
|
|
if (!valueVariance) return 0;
|
|
|
|
return valueVariance / value * 100;
|
|
|
|
}
|
|
|
|
|
2021-01-28 09:25:49 +00:00
|
|
|
add(entry) {
|
2021-03-17 10:07:14 +00:00
|
|
|
if (this.name !== entry.name) {
|
2021-01-28 09:25:49 +00:00
|
|
|
console.error("Should not combine entries with different names");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this._time += entry._time;
|
|
|
|
this._count += entry._count;
|
|
|
|
}
|
2016-11-22 10:12:53 +00:00
|
|
|
urlParams() {
|
2020-06-30 08:24:58 +00:00
|
|
|
let params = this.page.urlParams();
|
2016-11-22 10:12:53 +00:00
|
|
|
params.entry = this.name;
|
|
|
|
return params;
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
getCompareWithBaseline(value, property) {
|
|
|
|
if (baselineVersion == undefined) return value;
|
2020-06-30 08:24:58 +00:00
|
|
|
let baselineEntry = baselineVersion.getEntry(this);
|
2016-05-06 13:23:51 +00:00
|
|
|
if (!baselineEntry) return value;
|
|
|
|
if (baselineVersion === this.page.version) return value;
|
|
|
|
return value - baselineEntry[property];
|
|
|
|
}
|
|
|
|
cssClass() {
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
get time() {
|
|
|
|
return this.getCompareWithBaseline(this._time, '_time');
|
|
|
|
}
|
|
|
|
get count() {
|
|
|
|
return this.getCompareWithBaseline(this._count, '_count');
|
|
|
|
}
|
|
|
|
get timePercent() {
|
2020-06-30 08:24:58 +00:00
|
|
|
let value = this._time / this.page.total._time * 100;
|
2016-05-06 13:23:51 +00:00
|
|
|
if (baselineVersion == undefined) return value;
|
2020-06-30 08:24:58 +00:00
|
|
|
let baselineEntry = baselineVersion.getEntry(this);
|
2016-05-06 13:23:51 +00:00
|
|
|
if (!baselineEntry) return value;
|
2016-05-11 12:32:27 +00:00
|
|
|
if (baselineVersion === this.page.version) return value;
|
|
|
|
return (this._time - baselineEntry._time) / this.page.total._time *
|
|
|
|
100;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2016-06-06 13:07:20 +00:00
|
|
|
get timePercentPerEntry() {
|
2020-06-30 08:24:58 +00:00
|
|
|
let value = this._time / this.page.total._time * 100;
|
2016-06-06 13:07:20 +00:00
|
|
|
if (baselineVersion == undefined) return value;
|
2020-06-30 08:24:58 +00:00
|
|
|
let baselineEntry = baselineVersion.getEntry(this);
|
2016-06-06 13:07:20 +00:00
|
|
|
if (!baselineEntry) return value;
|
|
|
|
if (baselineVersion === this.page.version) return value;
|
|
|
|
return (this._time / baselineEntry._time - 1) * 100;
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
get timePercentVariancePercent() {
|
|
|
|
// Get the absolute values for the percentages
|
|
|
|
return this.timeVariance / this.page.total._time * 100;
|
|
|
|
}
|
|
|
|
getTimeImpact(showDiff) {
|
|
|
|
return this.page.version.getTotalTime(this.name, showDiff);
|
|
|
|
}
|
|
|
|
getTimeImpactVariancePercent(showDiff) {
|
2016-05-11 12:32:27 +00:00
|
|
|
return this.page.version.getTotalTimeVariancePercent(this.name, showDiff);
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
getTimePercentImpact(showDiff) {
|
|
|
|
return this.page.version.getTotalTimePercent(this.name, showDiff);
|
|
|
|
}
|
|
|
|
getCountImpact(showDiff) {
|
|
|
|
return this.page.version.getTotalCount(this.name, showDiff);
|
|
|
|
}
|
2016-06-06 13:07:20 +00:00
|
|
|
getAverageTimeImpact(showDiff) {
|
|
|
|
return this.page.version.getAverageTimeImpact(this.name, showDiff);
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
getPagesByPercentImpact() {
|
|
|
|
return this.page.version.getPagesByPercentImpact(this.name);
|
|
|
|
}
|
|
|
|
get isGroup() {
|
2021-03-17 10:07:14 +00:00
|
|
|
return false;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
get timeVariance() {
|
2021-03-17 10:07:14 +00:00
|
|
|
return this._timeVariance;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
get timeVariancePercent() {
|
2021-03-17 10:07:14 +00:00
|
|
|
return this._timeVariancePercent;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2020-04-28 10:38:25 +00:00
|
|
|
|
|
|
|
static fromLegacyJSON(position, data) {
|
|
|
|
return new Entry(position, ...data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static fromJSON(position, name, data) {
|
|
|
|
let time = data.duration;
|
|
|
|
let count = data.count;
|
|
|
|
return new Entry(position, name, time.average, time.stddev, 0,
|
2021-03-17 10:07:14 +00:00
|
|
|
count.average, count.stddev, 0);
|
2020-04-28 10:38:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static fromTXT(position, splitLine) {
|
2021-03-17 10:07:14 +00:00
|
|
|
const name = splitLine[0];
|
|
|
|
let time = splitLine[1];
|
|
|
|
const msIndex = time.indexOf('m');
|
|
|
|
if (msIndex > 0) time = time.substring(0, msIndex);
|
|
|
|
const timePercent = splitLine[2];
|
|
|
|
const count = splitLine[3];
|
|
|
|
const countPercent = splitLine[4];
|
|
|
|
const timeDeviation = 0;
|
|
|
|
const countDeviation = 0;
|
|
|
|
const timeDeviationPercent = 0;
|
|
|
|
const countDeviationPercent = 0
|
2020-04-28 10:38:25 +00:00
|
|
|
return new Entry(position, name,
|
|
|
|
Number.parseFloat(time), timeDeviation, timeDeviationPercent,
|
|
|
|
Number.parseInt(count), countDeviation, countDeviationPercent)
|
|
|
|
}
|
2020-02-19 16:42:44 +00:00
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
|
2017-02-08 17:29:56 +00:00
|
|
|
class Group {
|
2021-03-17 10:07:14 +00:00
|
|
|
constructor(name, regexp, color, enabled = true, addsToTotal = true) {
|
2016-09-28 07:49:45 +00:00
|
|
|
this.name = name;
|
2016-05-06 13:23:51 +00:00
|
|
|
this.regexp = regexp;
|
2016-06-06 13:07:20 +00:00
|
|
|
this.color = color;
|
2020-06-30 08:24:58 +00:00
|
|
|
this.enabled = enabled;
|
2021-02-08 11:37:32 +00:00
|
|
|
this.addsToTotal = addsToTotal;
|
2016-09-28 07:49:45 +00:00
|
|
|
}
|
2021-03-17 10:07:14 +00:00
|
|
|
entry() {
|
|
|
|
return new GroupedEntry(this);
|
|
|
|
}
|
2016-09-28 07:49:45 +00:00
|
|
|
}
|
|
|
|
Group.groups = new Map();
|
2021-03-17 10:07:14 +00:00
|
|
|
Group.add = function (name, group) {
|
2016-09-28 07:49:45 +00:00
|
|
|
this.groups.set(name, group);
|
2016-11-16 18:51:32 +00:00
|
|
|
return group;
|
2016-09-28 07:49:45 +00:00
|
|
|
}
|
2020-06-30 08:24:58 +00:00
|
|
|
Group.add('total', new Group('Total', /.*Total.*/, '#BBB', true, false));
|
2021-02-08 11:37:32 +00:00
|
|
|
Group.add('ic', new Group('IC', /(.*IC_.*)|IC/, "#3366CC"));
|
2018-09-06 14:23:36 +00:00
|
|
|
Group.add('optimize-background', new Group('Optimize-Background',
|
2021-03-17 10:07:14 +00:00
|
|
|
/.*Optimize(d?-?)(Background|Concurrent).*/, "#702000"));
|
2016-09-28 07:49:45 +00:00
|
|
|
Group.add('optimize', new Group('Optimize',
|
2021-03-17 10:07:14 +00:00
|
|
|
/(StackGuard|Optimize|Deoptimize|Recompile).*/, "#DC3912"));
|
2017-01-03 18:11:58 +00:00
|
|
|
Group.add('compile-background', new Group('Compile-Background',
|
2021-03-17 10:07:14 +00:00
|
|
|
/(.*Compile-?Background.*)/, "#b08000"));
|
2016-12-08 11:35:06 +00:00
|
|
|
Group.add('compile', new Group('Compile',
|
2021-03-17 10:07:14 +00:00
|
|
|
/(^Compile.*)|(.*_Compile.*)/, "#FFAA00"));
|
2016-11-16 18:51:32 +00:00
|
|
|
Group.add('parse-background',
|
2021-03-17 10:07:14 +00:00
|
|
|
new Group('Parse-Background', /.*Parse-?Background.*/, "#c05000"));
|
2016-09-28 07:49:45 +00:00
|
|
|
Group.add('parse', new Group('Parse', /.*Parse.*/, "#FF6600"));
|
2021-02-08 11:37:32 +00:00
|
|
|
Group.add('callback',
|
2021-03-17 10:07:14 +00:00
|
|
|
new Group('Blink C++', /.*(Callback)|(Blink C\+\+).*/, "#109618"));
|
2016-09-28 07:49:45 +00:00
|
|
|
Group.add('api', new Group('API', /.*API.*/, "#990099"));
|
2017-08-01 13:28:52 +00:00
|
|
|
Group.add('gc-custom', new Group('GC-Custom', /GC_Custom_.*/, "#0099C6"));
|
2017-12-04 14:51:04 +00:00
|
|
|
Group.add('gc-background',
|
2021-03-17 10:07:14 +00:00
|
|
|
new Group(
|
|
|
|
'GC-Background', /.*GC.*(BACKGROUND|Background).*/, "#00597c"));
|
2021-02-08 11:37:32 +00:00
|
|
|
Group.add('gc',
|
2021-03-17 10:07:14 +00:00
|
|
|
new Group('GC', /GC_.*|AllocateInTargetSpace|GC/, "#00799c"));
|
2021-02-08 11:37:32 +00:00
|
|
|
Group.add('javascript',
|
2021-03-17 10:07:14 +00:00
|
|
|
new Group('JavaScript', /JS_Execution|JavaScript/, "#DD4477"));
|
2016-12-22 14:08:54 +00:00
|
|
|
Group.add('runtime', new Group('V8 C++', /.*/, "#88BB00"));
|
2021-02-08 11:37:32 +00:00
|
|
|
Group.add('blink',
|
2021-03-17 10:07:14 +00:00
|
|
|
new Group('Blink RCS', /.*Blink_.*/, "#006600", false, false));
|
2020-06-30 08:24:58 +00:00
|
|
|
Group.add('unclassified', new Group('Unclassified', /.*/, "#000", false));
|
2016-09-28 07:49:45 +00:00
|
|
|
|
|
|
|
class GroupedEntry extends Entry {
|
|
|
|
constructor(group) {
|
2016-10-26 12:20:03 +00:00
|
|
|
super(0, GroupedEntry.prefix + group.name, 0, 0, 0, 0, 0, 0);
|
2016-09-28 07:49:45 +00:00
|
|
|
this.group = group;
|
2016-05-06 13:23:51 +00:00
|
|
|
this.entries = [];
|
2017-03-01 13:28:06 +00:00
|
|
|
this.missingEntries = null;
|
2020-06-30 08:24:58 +00:00
|
|
|
this.addsToTotal = group.addsToTotal;
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
2021-03-17 10:07:14 +00:00
|
|
|
get regexp() {
|
|
|
|
return this.group.regexp;
|
|
|
|
}
|
|
|
|
get color() {
|
|
|
|
return this.group.color;
|
|
|
|
}
|
|
|
|
get enabled() {
|
|
|
|
return this.group.enabled;
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
add(entry) {
|
2021-01-28 09:25:49 +00:00
|
|
|
if (!this.addTimeAndCount(entry)) return;
|
2016-05-06 13:23:51 +00:00
|
|
|
// TODO: sum up variance
|
|
|
|
this.entries.push(entry);
|
|
|
|
entry.parent = this;
|
|
|
|
return true;
|
|
|
|
}
|
2021-01-28 09:25:49 +00:00
|
|
|
addTimeAndCount(entry) {
|
|
|
|
if (!this.regexp.test(entry.name)) return false;
|
|
|
|
this._time += entry.time;
|
|
|
|
this._count += entry.count;
|
|
|
|
return true;
|
|
|
|
}
|
2017-03-01 13:28:06 +00:00
|
|
|
_initializeMissingEntries() {
|
2020-06-30 08:24:58 +00:00
|
|
|
let dummyEntryNames = new Set();
|
2017-02-08 17:29:56 +00:00
|
|
|
versions.forEach((version) => {
|
2021-02-08 11:37:32 +00:00
|
|
|
let page = version.getOrCreate(this.page.name);
|
|
|
|
let groupEntry = page.get(this.name);
|
2017-02-08 17:29:56 +00:00
|
|
|
if (groupEntry != this) {
|
2020-06-30 08:24:58 +00:00
|
|
|
for (let entry of groupEntry.entries) {
|
2017-02-08 17:29:56 +00:00
|
|
|
if (this.page.get(entry.name) == undefined) {
|
|
|
|
dummyEntryNames.add(entry.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-06 13:23:51 +00:00
|
|
|
});
|
2021-03-17 10:07:14 +00:00
|
|
|
this.missingEntries = [];
|
2020-06-30 08:24:58 +00:00
|
|
|
for (let name of dummyEntryNames) {
|
|
|
|
let tmpEntry = new Entry(0, name, 0, 0, 0, 0, 0, 0);
|
2017-02-08 17:29:56 +00:00
|
|
|
tmpEntry.page = this.page;
|
2017-03-01 13:28:06 +00:00
|
|
|
this.missingEntries.push(tmpEntry);
|
2017-02-08 17:29:56 +00:00
|
|
|
};
|
2017-03-01 13:28:06 +00:00
|
|
|
}
|
|
|
|
forEach(fun) {
|
|
|
|
// Show also all entries which are in at least one version.
|
2017-02-08 17:29:56 +00:00
|
|
|
// Concatenate our real entries.
|
2017-03-01 13:28:06 +00:00
|
|
|
if (this.missingEntries == null) {
|
|
|
|
this._initializeMissingEntries();
|
|
|
|
}
|
2020-06-30 08:24:58 +00:00
|
|
|
let tmpEntries = this.missingEntries.concat(this.entries);
|
2017-02-08 17:29:56 +00:00
|
|
|
|
|
|
|
// The compared entries are sorted by absolute impact.
|
2016-05-06 13:23:51 +00:00
|
|
|
tmpEntries.sort((a, b) => {
|
2017-03-01 13:28:06 +00:00
|
|
|
return b.time - a.time
|
2016-05-06 13:23:51 +00:00
|
|
|
});
|
|
|
|
tmpEntries.forEach(fun);
|
|
|
|
}
|
|
|
|
sort() {
|
|
|
|
this.entries.sort((a, b) => {
|
|
|
|
return b.time - a.time;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
cssClass() {
|
|
|
|
if (this.page.total == this) return 'total';
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
get isGroup() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
getVarianceForProperty(property) {
|
2020-06-30 08:24:58 +00:00
|
|
|
let sum = 0;
|
2021-02-08 11:37:32 +00:00
|
|
|
const key = property + 'Variance';
|
2016-05-06 13:23:51 +00:00
|
|
|
this.entries.forEach((entry) => {
|
2021-02-08 11:37:32 +00:00
|
|
|
const value = entry[key];
|
|
|
|
sum += value * value;
|
2016-05-06 13:23:51 +00:00
|
|
|
});
|
|
|
|
return Math.sqrt(sum);
|
|
|
|
}
|
|
|
|
get timeVariancePercent() {
|
|
|
|
if (this._time == 0) return 0;
|
2021-03-17 10:07:14 +00:00
|
|
|
return this.getVarianceForProperty('time') / this._time * 100
|
2016-05-06 13:23:51 +00:00
|
|
|
}
|
|
|
|
get timeVariance() {
|
|
|
|
return this.getVarianceForProperty('time')
|
|
|
|
}
|
|
|
|
}
|
2016-10-26 12:20:03 +00:00
|
|
|
GroupedEntry.prefix = 'Group-';
|
2016-05-06 13:23:51 +00:00
|
|
|
|
|
|
|
class UnclassifiedEntry extends GroupedEntry {
|
2016-09-28 07:49:45 +00:00
|
|
|
constructor(page) {
|
|
|
|
super(Group.groups.get('unclassified'));
|
2016-05-06 13:23:51 +00:00
|
|
|
this.page = page;
|
|
|
|
this._time = undefined;
|
|
|
|
this._count = undefined;
|
|
|
|
}
|
|
|
|
add(entry) {
|
2020-06-30 08:24:58 +00:00
|
|
|
console.log("Adding unclassified:", entry);
|
2016-05-06 13:23:51 +00:00
|
|
|
this.entries.push(entry);
|
|
|
|
entry.parent = this;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
forEachPageGroup(fun) {
|
|
|
|
this.page.forEachGroup((group) => {
|
|
|
|
if (group == this) return;
|
|
|
|
if (group == this.page.total) return;
|
|
|
|
fun(group);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
get time() {
|
|
|
|
if (this._time === undefined) {
|
|
|
|
this._time = this.page.total._time;
|
|
|
|
this.forEachPageGroup((group) => {
|
2020-06-30 08:24:58 +00:00
|
|
|
if (group.addsToTotal) this._time -= group._time;
|
2016-05-06 13:23:51 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
return this.getCompareWithBaseline(this._time, '_time');
|
|
|
|
}
|
|
|
|
get count() {
|
|
|
|
if (this._count === undefined) {
|
|
|
|
this._count = this.page.total._count;
|
|
|
|
this.forEachPageGroup((group) => {
|
|
|
|
this._count -= group._count;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return this.getCompareWithBaseline(this._count, '_count');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
|
2016-06-06 13:07:20 +00:00
|
|
|
<body id="body" onmousemove="handleUpdatePopover(event)" onload="handleBodyLoad()" class="noDiff">
|
2016-05-06 13:23:51 +00:00
|
|
|
<h1>Runtime Stats Komparator</h1>
|
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
<section id="inputs" class="panel alwaysVisible">
|
|
|
|
<input type="checkbox" id="inputsCheckbox" class="panelCloserInput">
|
|
|
|
<label class="panelCloserLabel" for="inputsCheckbox">▼</label>
|
|
|
|
<h2>Input/Output</h2>
|
2021-03-17 10:07:14 +00:00
|
|
|
<div class="panelBody">
|
2021-03-02 13:56:46 +00:00
|
|
|
<form name="fileForm" class="inline">
|
|
|
|
<p class="inline">
|
|
|
|
<label for="uploadInput">Load Files:</label>
|
2021-03-17 10:07:14 +00:00
|
|
|
<input id="uploadInput" type="file" name="files" onchange="handleLoadFiles();" multiple
|
|
|
|
accept=".json,.txt,.csv,.output">
|
2016-05-06 13:23:51 +00:00
|
|
|
</p>
|
2021-03-02 13:56:46 +00:00
|
|
|
<p class="inline">
|
2021-01-28 09:25:49 +00:00
|
|
|
<label for="appendInput">Append Files:</label>
|
2021-03-17 10:07:14 +00:00
|
|
|
<input id="appendInput" type="file" name="files" onchange="handleAppendFiles();" multiple
|
|
|
|
accept=".json,.txt,.csv,.output">
|
2017-03-09 09:53:34 +00:00
|
|
|
</p>
|
2016-05-06 13:23:51 +00:00
|
|
|
</form>
|
2021-03-02 13:56:46 +00:00
|
|
|
<p class="inline">
|
2021-01-28 09:25:49 +00:00
|
|
|
<button onclick="handleCopyToClipboard()">Copy Table to Clipboard</button>
|
|
|
|
</p>
|
2016-05-06 13:23:51 +00:00
|
|
|
</div>
|
2021-03-02 13:56:46 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section class="panel">
|
|
|
|
<h2>Baseline Selector</h2>
|
|
|
|
<div class="panel-body">
|
2021-03-17 10:07:14 +00:00
|
|
|
Compare against baseline: <select id="baseline" onchange="handleSelectBaseline(this, event)"></select><br />
|
2021-03-02 13:56:46 +00:00
|
|
|
<span style="color: #060">Green</span> a selected version performs
|
|
|
|
better than the baseline.
|
2016-06-06 13:07:20 +00:00
|
|
|
</div>
|
2021-03-02 13:56:46 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section class="panel-group">
|
|
|
|
<div id="versionSelector" class="panel">
|
|
|
|
<input type="checkbox" checked id="versionSelectorCheckbox" class="panelCloserInput">
|
|
|
|
<label class="panelCloserLabel" for="versionSelectorCheckbox">▼</label>
|
|
|
|
<h2>Selected Versions</h2>
|
|
|
|
<div class="panelBody">
|
2016-05-11 12:32:27 +00:00
|
|
|
<ul></ul>
|
|
|
|
</div>
|
2016-05-06 13:23:51 +00:00
|
|
|
</div>
|
2017-02-08 17:29:56 +00:00
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
<div id="pageSelector" class="panel">
|
|
|
|
<input type="checkbox" checked id="pageSelectorCheckbox" class="panelCloserInput">
|
|
|
|
<label class="panelCloserLabel" for="pageSelectorCheckbox">▼</label>
|
|
|
|
<h2>Selected Pages</h2>
|
|
|
|
<div class="panelBody">
|
2016-09-28 07:49:45 +00:00
|
|
|
<ul></ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
<div id="groupSelector" class="panel">
|
|
|
|
<input type="checkbox" checked id="groupSelectorCheckbox" class="panelCloserInput">
|
|
|
|
<label class="panelCloserLabel" for="groupSelectorCheckbox">▼</label>
|
|
|
|
<h2>Selected RCS Groups</h2>
|
|
|
|
<div class="panelBody">
|
2016-06-06 13:07:20 +00:00
|
|
|
<ul></ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-03-02 13:56:46 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="view" class="panel">
|
|
|
|
<input type="checkbox" id="tableViewCheckbox" class="panelCloserInput">
|
|
|
|
<label class="panelCloserLabel" for="tableViewCheckbox">▼</label>
|
|
|
|
<h2>RCS Table</h2>
|
|
|
|
<div class="panelBody"></div>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section class="panel-group">
|
|
|
|
<div id="versionDetails" class="panel">
|
|
|
|
<input type="checkbox" checked id="versionDetailCheckbox" class="panelCloserInput">
|
|
|
|
<label class="panelCloserLabel" for="versionDetailCheckbox">▼</label>
|
|
|
|
<h2><span>Compare Page Versions</span></h2>
|
|
|
|
<div class="conten panelBody">
|
|
|
|
<table class="versionDetailTable" onclick="handleSelectDetailRow(this, event);">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th class="version">Version </th>
|
|
|
|
<th class="position">Pos. </th>
|
|
|
|
<th class="value time">Time▴ </th>
|
|
|
|
<th class="value time">Percent </th>
|
|
|
|
<th class="value count">Count </th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody></tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2016-05-06 13:23:51 +00:00
|
|
|
</div>
|
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
<div id="pageDetail" class="panel">
|
|
|
|
<input type="checkbox" checked id="pageDetailCheckbox" class="panelCloserInput">
|
|
|
|
<label class="panelCloserLabel" for="pageDetailCheckbox">▼</label>
|
|
|
|
<h2>Page Comparison for <span></span></h2>
|
|
|
|
<div class="panelBody">
|
|
|
|
<table class="pageDetailTable" onclick="handleSelectDetailRow(this, event);">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th class="page">Page </th>
|
|
|
|
<th class="value time">Time </th>
|
|
|
|
<th class="value time">Percent▾ </th>
|
|
|
|
<th class="value time hideNoDiff">%/Entry </th>
|
|
|
|
<th class="value count">Count </th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tfoot>
|
|
|
|
<tr>
|
|
|
|
<td class="page">Total:</td>
|
|
|
|
<td class="value time"></td>
|
|
|
|
<td class="value time"></td>
|
|
|
|
<td class="value time hideNoDiff"></td>
|
|
|
|
<td class="value count"></td>
|
|
|
|
</tr>
|
|
|
|
</tfoot>
|
|
|
|
<tbody></tbody>
|
|
|
|
</table>
|
2016-05-06 13:23:51 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-03-02 13:56:46 +00:00
|
|
|
|
|
|
|
<div id="impactView" class="panel">
|
2021-03-17 10:07:14 +00:00
|
|
|
<input type="checkbox" checked id="impactViewCheckbox" class="panelCloserInput">
|
2021-03-02 13:56:46 +00:00
|
|
|
<label class="panelCloserLabel" for="impactViewCheckbox">▼</label>
|
|
|
|
<h2>Impact list for <span></span></h2>
|
|
|
|
<div class="panelBody">
|
|
|
|
<table class="pageDetailTable" onclick="handleSelectDetailRow(this, event);">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th class="page">Name </th>
|
|
|
|
<th class="value time">Time </th>
|
|
|
|
<th class="value time">Percent▾ </th>
|
|
|
|
<th class="">Top Pages</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody></tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2016-06-06 13:07:20 +00:00
|
|
|
</div>
|
2021-03-02 13:56:46 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="pageVersionGraph" class="panel">
|
|
|
|
<input type="checkbox" id="pageVersionGraphCheckbox" class="panelCloserInput">
|
|
|
|
<label class="panelCloserLabel" for="pageVersionGraphCheckbox">▼</label>
|
|
|
|
<h2><span></span></h2>
|
|
|
|
<div class="panelBody"></div>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="pageGraph" class="panel">
|
|
|
|
<input type="checkbox" id="pageGraphCheckbox" class="panelCloserInput">
|
|
|
|
<label class="panelCloserLabel" for="pageGraphCheckbox">▼</label>
|
|
|
|
<h2><span></span></h2>
|
|
|
|
<div class="panelBody"></div>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="versionGraph" class="panel">
|
|
|
|
<input type="checkbox" id="versionGraphCheckbox" class="panelCloserInput">
|
|
|
|
<label class="panelCloserLabel" for="versionGraphCheckbox">▼</label>
|
|
|
|
<h2><span></span></h2>
|
|
|
|
<div class="panelBody"></div>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<div id="column" class="column">
|
|
|
|
<div class="header">
|
|
|
|
<select class="version" onchange="handleSelectVersion(this, event);"></select>
|
|
|
|
<select class="pageVersion" onchange="handleSelectPage(this, event);"></select>
|
2016-06-06 13:07:20 +00:00
|
|
|
</div>
|
2021-03-02 13:56:46 +00:00
|
|
|
<table class="list" onclick="handleSelectRow(this, event);">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th class="position">Pos. </th>
|
|
|
|
<th class="name">Name </th>
|
|
|
|
<th class="value time">Time </th>
|
|
|
|
<th class="value time">Percent </th>
|
|
|
|
<th class="value count">Count </th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody></tbody>
|
|
|
|
</table>
|
2021-03-17 10:07:14 +00:00
|
|
|
</div>
|
2016-05-06 13:23:51 +00:00
|
|
|
|
2021-03-02 13:56:46 +00:00
|
|
|
<section class="panel alwaysVisible">
|
|
|
|
<h2>Instructions</h2>
|
|
|
|
<div class="panelBody">
|
|
|
|
<ol>
|
|
|
|
<li>Build chrome.</li>
|
|
|
|
</ol>
|
|
|
|
<h3>Telemetry benchmark</h3>
|
|
|
|
<ol>
|
|
|
|
<li>Run <code>v8.browsing</code> benchmarks:
|
|
|
|
<pre>$CHROMIUM_DIR/tools/perf/run_benchmark run v8.browsing_desktop \
|
|
|
|
--browser=exact --browser-executable=$CHROMIUM_DIR/out/release/chrome \
|
|
|
|
--story-filter='.*2020 ' \
|
|
|
|
--also-run-disabled-tests
|
|
|
|
</pre>
|
|
|
|
</li>
|
|
|
|
<li>Install <a href="https://stedolan.github.io/jq/">jq</a>.</li>
|
|
|
|
<li>Convert the telemetry JSON files to callstats JSON file:
|
|
|
|
<pre>
|
|
|
|
$V8_DIR/tools/callstats-from-telemetry.sh $CHROMIUM_DIR/tools/perf/artifacts/run_XXXX
|
|
|
|
</pre>
|
|
|
|
</li>
|
|
|
|
<li>Load the generated <code>out.json</code></li>
|
|
|
|
</ol>
|
|
|
|
<h3>Merged CSV from results.html</h3>
|
|
|
|
<ol>
|
|
|
|
<li>Open a results.html page for RCS-enabled benchmarks</li>
|
|
|
|
<li>Select "Export merged CSV" in the toolbar</li>
|
|
|
|
<li>Load the downloading .csv file normally in callstats.html</li>
|
|
|
|
</ol>
|
|
|
|
<h3>Aggregated raw txt output</h3>
|
|
|
|
<ol>
|
|
|
|
<li>Install scipy, e.g. <code>sudo aptitude install python-scipy</code>
|
|
|
|
<li>Check out a known working version of webpagereply:
|
|
|
|
<pre>git -C $CHROME_DIR/third_party/webpagereplay checkout 7dbd94752d1cde5536ffc623a9e10a51721eff1d</pre>
|
|
|
|
</li>
|
|
|
|
<li>Run <code>callstats.py</code> with a web-page-replay archive:
|
|
|
|
<pre>$V8_DIR/tools/callstats.py run \
|
|
|
|
--replay-bin=$CHROME_SRC/third_party/webpagereplay/replay.py \
|
|
|
|
--replay-wpr=$INPUT_DIR/top25.wpr \
|
|
|
|
--js-flags="" \
|
|
|
|
--with-chrome=$CHROME_SRC/out/Release/chrome \
|
|
|
|
--sites-file=$INPUT_DIR/top25.json</pre>
|
|
|
|
</li>
|
|
|
|
<li>Move results file to a subdirectory: <code>mkdir $VERSION_DIR; mv *.txt $VERSION_DIR</code></li>
|
|
|
|
<li>Repeat from step 1 with a different configuration (e.g. <code>--js-flags="--nolazy"</code>).</li>
|
2021-03-17 10:07:14 +00:00
|
|
|
<li>Create the final results file: <code>./callstats.py json $VERSION_DIR1 $VERSION_DIR2 > result.json</code>
|
|
|
|
</li>
|
2021-03-02 13:56:46 +00:00
|
|
|
<li>Use <code>results.json</code> on this site.</code>
|
|
|
|
</ol>
|
2016-05-06 13:23:51 +00:00
|
|
|
</div>
|
2021-03-02 13:56:46 +00:00
|
|
|
</section>
|
2016-05-06 13:23:51 +00:00
|
|
|
|
|
|
|
<div id="popover">
|
|
|
|
<div class="popoverArrow"></div>
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<td class="name" colspan="6"></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Page:</td>
|
|
|
|
<td class="page name" colspan="6"></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Version:</td>
|
|
|
|
<td class="version name" colspan="3"></td>
|
|
|
|
<td class="compare version name" colspan="3"></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Time:</td>
|
2021-03-17 10:07:14 +00:00
|
|
|
<td class="time"></td>
|
|
|
|
<td>±</td>
|
|
|
|
<td class="timeVariance"></td>
|
|
|
|
<td class="compare time"></td>
|
|
|
|
<td class="compare"> ± </td>
|
|
|
|
<td class="compare timeVariance"></td>
|
2016-05-06 13:23:51 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Percent:</td>
|
2021-03-17 10:07:14 +00:00
|
|
|
<td class="percent"></td>
|
|
|
|
<td>±</td>
|
|
|
|
<td class="percentVariance"></td>
|
|
|
|
<td class="compare percent"></td>
|
|
|
|
<td class="compare"> ± </td>
|
|
|
|
<td class="compare percentVariance"></td>
|
2016-05-06 13:23:51 +00:00
|
|
|
</tr>
|
2016-06-06 13:07:20 +00:00
|
|
|
<tr>
|
|
|
|
<td>Percent per Entry:</td>
|
2021-03-17 10:07:14 +00:00
|
|
|
<td class="percentPerEntry"></td>
|
|
|
|
<td colspan=2></td>
|
|
|
|
<td class="compare percentPerEntry"></td>
|
|
|
|
<td colspan=2></td>
|
2016-06-06 13:07:20 +00:00
|
|
|
</tr>
|
2016-05-06 13:23:51 +00:00
|
|
|
<tr>
|
|
|
|
<td>Count:</td>
|
2021-03-17 10:07:14 +00:00
|
|
|
<td class="count"></td>
|
|
|
|
<td>±</td>
|
|
|
|
<td class="countVariance"></td>
|
|
|
|
<td class="compare count"></td>
|
|
|
|
<td class="compare"> ± </td>
|
|
|
|
<td class="compare countVariance"></td>
|
2016-05-06 13:23:51 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Overall Impact:</td>
|
2021-03-17 10:07:14 +00:00
|
|
|
<td class="timeImpact"></td>
|
|
|
|
<td>±</td>
|
|
|
|
<td class="timePercentImpact"></td>
|
|
|
|
<td class="compare timeImpact"></td>
|
|
|
|
<td class="compare"> ± </td>
|
|
|
|
<td class="compare timePercentImpact"></td>
|
2016-05-06 13:23:51 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</body>
|
2021-03-17 10:07:14 +00:00
|
|
|
|
|
|
|
</html>
|