Skip to content

Commit

Permalink
add toggle between linear and log
Browse files Browse the repository at this point in the history
  • Loading branch information
s7tya committed Oct 10, 2024
1 parent 8f93b9b commit 6a911fe
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
24 changes: 20 additions & 4 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,8 +60,8 @@ function render(
},
yAxis: {
title: {text: "Seconds"},
min: Math.min(...Object.keys(data).flatMap((key) => data[key])),
type: "logarithmic",
min: scale === "linear" ? 0 : undefined,
type: scale === "log" ? "logarithmic" : undefined,
},
xAxis: {
categories: versions,
Expand Down Expand Up @@ -101,8 +117,8 @@ function renderRuntime(element: string, data: [number], versions: [string]) {
},
yAxis: {
title: {text: "Miliseconds"},
min: Math.min(...formattedData),
type: "logarithmic",
min: scale === "linear" ? 0 : undefined,
type: scale === "log" ? "logarithmic" : undefined,
},
xAxis: {
categories: versions.slice(nullCount),
Expand Down
3 changes: 2 additions & 1 deletion site/frontend/src/urls.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const BASE_URL = window.location.origin + "/perf";
// const BASE_URL = window.location.origin + "/perf";
const BASE_URL = "https://perf.rust-lang.org/perf";

export const INFO_URL = `${BASE_URL}/info`;

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 6a911fe

Please sign in to comment.