Skip to content

Commit

Permalink
Merge pull request #1990 from s7tya/log-scale-dashboard
Browse files Browse the repository at this point in the history
Add an option to switch between linear scale and log scale on the dashboard page.
  • Loading branch information
Kobzol authored Oct 11, 2024
2 parents 1cbb6b3 + b4f6ba6 commit ce77826
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
28 changes: 25 additions & 3 deletions site/frontend/src/pages/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ import {DASHBOARD_DATA_URL} from "../urls";

import {getJson} from "../utils/requests";

type ScaleKind = "linear" | "log";
let scale: ScaleKind = "linear";

const buttons = Array.from(
document.querySelectorAll<HTMLInputElement>("#scale-select-form input")
);

buttons.map((button) => {
button.addEventListener("change", () => {
if (button.checked) {
scale = button.value as ScaleKind;
make_data();
}
});
});

interface DashboardCompileBenchmarkCases {
clean_averages: [number];
base_incr_averages: [number];
Expand Down Expand Up @@ -44,7 +60,8 @@ function render(
},
yAxis: {
title: {text: "Seconds"},
min: 0,
min: scale === "linear" ? 0 : undefined,
type: scale === "log" ? "logarithmic" : undefined,
},
xAxis: {
categories: versions,
Expand Down Expand Up @@ -100,7 +117,8 @@ function renderRuntime(element: string, data: [number], versions: [string]) {
},
yAxis: {
title: {text: "Miliseconds"},
min: 0,
min: scale === "linear" ? 0 : undefined,
type: scale === "log" ? "logarithmic" : undefined,
},
xAxis: {
categories: versions.slice(nullCount),
Expand All @@ -126,8 +144,12 @@ function populate_data(response: DashboardResponse) {
renderRuntime("runtime-average-times", data.runtime, data.versions);
}

let response: DashboardResponse | null = null;
async function make_data() {
const response = await getJson<DashboardResponse>(DASHBOARD_DATA_URL);
if (!response) {
response = await getJson<DashboardResponse>(DASHBOARD_DATA_URL);
}

populate_data(response);
}

Expand Down
11 changes: 11 additions & 0 deletions site/frontend/templates/pages/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
compiled by a given version of the Rust compiler.
</details>

<form id="scale-select-form">
<label>
<input type="radio" name="scale-select" value="linear" checked />
Linear-scale
</label>
<label>
<input type="radio" name="scale-select" value="log" />
Log-scale
</label>
</form>

<div class="graphs">
<div id="check-average-times"></div>
<div id="debug-average-times"></div>
Expand Down

0 comments on commit ce77826

Please sign in to comment.