blob: d83e08141922bc92f7e68f84250660a8b874a2ff [file] [log] [blame]
<!--
Copyright 2022 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Go Performance Dashboard</title>
<link rel="icon" href="https://go.dev/favicon.ico"/>
<link rel="stylesheet" href="./static/style.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/d3js/7.4.2/d3.min.js"></script>
<script src="./third_party/bandchart/bandchart.js"></script>
</head>
<body class="Dashboard">
<header class="Dashboard-topbar">
<h1>
<a href="./">Go Performance Dashboard</a>
</h1>
<nav>
<ul>
<li><a href="https://build.golang.org">Build Dashboard</a></li>
</ul>
</nav>
</header>
<form autocomplete="off" action="./">
<nav class="Dashboard-controls">
<div class="Dashboard-search">
<input id="benchmarkInput" type="text" name="benchmark" placeholder="Type benchmark name...">
</div>
<input type="submit">
</nav>
</form>
<script>
</script>
<div id="dashboard"></div>
<script>
function addContent(benchmarks) {
let dashboard = document.getElementById("dashboard");
let prevName = "";
let grid = null;
for (const b in benchmarks) {
const bench = benchmarks[b];
if (bench.Name != prevName) {
prevName = bench.Name;
let title = document.createElement("h2");
title.classList.add("Dashboard-title");
title.innerHTML = bench.Name;
dashboard.appendChild(title);
grid = document.createElement("grid");
grid.classList.add("Dashboard-grid");
dashboard.appendChild(grid);
}
let item = document.createElement("div");
item.classList.add("Dashboard-grid-item");
item.appendChild(BandChart(bench.Values, {
unit: bench.Unit,
}));
grid.appendChild(item);
}
}
function failure(name) {
let dashboard = document.getElementById("dashboard");
let title = document.createElement("h2");
title.classList.add("Dashboard-title");
title.innerHTML = "Benchmark \"" + name + "\" not found.";
dashboard.appendChild(title);
}
let benchmark = (new URLSearchParams(window.location.search)).get('benchmark');
let dataURL = './data.json';
if (benchmark) {
dataURL += '?benchmark=' + benchmark;
}
fetch(dataURL)
.then(response => {
if (!response.ok) {
throw new Error("Data fetch failed");
}
return response.json();
})
.then(function(benchmarks) {
// Convert CommitDate to a proper date.
benchmarks.forEach(function(b) {
b.Values.forEach(function(v) {
v.CommitDate = new Date(v.CommitDate);
});
});
addContent(benchmarks);
})
// This will look odd if the error isn't a 404 and benchmark is
// undefined, but close enough.
.catch(error => failure(benchmark));
</script>
</body>
</html>