<commit_before><!--
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>

<nav class="Dashboard-controls">
	<ul>
		<li>
			<form autocomplete="off" action="./">
				<div class="Dashboard-search">
					<input id="benchmarkInput" type="text" name="benchmark" placeholder="Type benchmark name...">
				</div>
				<input type="submit">
			</form>
		</li>
		<li><a href="?benchmark=all">All benchmarks</a></li>
	</ul>
</nav>

<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();
	})<commit_msg>perf: add loading message<commit_after><!--
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>

<nav class="Dashboard-controls">
	<ul>
		<li>
			<form autocomplete="off" action="./">
				<div class="Dashboard-search">
					<input id="benchmarkInput" type="text" name="benchmark" placeholder="Type benchmark name...">
				</div>
				<input type="submit">
			</form>
		</li>
		<li><a href="?benchmark=all">All benchmarks</a></li>
	</ul>
</nav>

<script>
</script>

<div id="dashboard">
	<h2 class="Dashboard-title" id="loading">Loading...</h2>
</div>

<script>
function removeLoadingMessage() {
	let loading = document.getElementById("loading");
	loading.parentNode.removeChild(loading);
}

function addContent(benchmarks) {
	let dashboard = document.getElementById("dashboard");

	removeLoadingMessage();

	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");

	removeLoadingMessage();

	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();
	})
{'fraction_non_alphanumeric': 0.18512009373169303, 'fraction_numerical': 0.0054676820933411445, 'mean_word_length': 4.397260273972603, 'pattern_counts': {'":': 0, '<': 103, '<?xml version=': 0, '>': 105, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3601718', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1728, 'n_words': 367}