Skip to content

Commit ce77826

Browse files
authored
Merge pull request #1990 from s7tya/log-scale-dashboard
Add an option to switch between linear scale and log scale on the dashboard page.
2 parents 1cbb6b3 + b4f6ba6 commit ce77826

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

site/frontend/src/pages/dashboard.ts

+25-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@ import {DASHBOARD_DATA_URL} from "../urls";
33

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

6+
type ScaleKind = "linear" | "log";
7+
let scale: ScaleKind = "linear";
8+
9+
const buttons = Array.from(
10+
document.querySelectorAll<HTMLInputElement>("#scale-select-form input")
11+
);
12+
13+
buttons.map((button) => {
14+
button.addEventListener("change", () => {
15+
if (button.checked) {
16+
scale = button.value as ScaleKind;
17+
make_data();
18+
}
19+
});
20+
});
21+
622
interface DashboardCompileBenchmarkCases {
723
clean_averages: [number];
824
base_incr_averages: [number];
@@ -44,7 +60,8 @@ function render(
4460
},
4561
yAxis: {
4662
title: {text: "Seconds"},
47-
min: 0,
63+
min: scale === "linear" ? 0 : undefined,
64+
type: scale === "log" ? "logarithmic" : undefined,
4865
},
4966
xAxis: {
5067
categories: versions,
@@ -100,7 +117,8 @@ function renderRuntime(element: string, data: [number], versions: [string]) {
100117
},
101118
yAxis: {
102119
title: {text: "Miliseconds"},
103-
min: 0,
120+
min: scale === "linear" ? 0 : undefined,
121+
type: scale === "log" ? "logarithmic" : undefined,
104122
},
105123
xAxis: {
106124
categories: versions.slice(nullCount),
@@ -126,8 +144,12 @@ function populate_data(response: DashboardResponse) {
126144
renderRuntime("runtime-average-times", data.runtime, data.versions);
127145
}
128146

147+
let response: DashboardResponse | null = null;
129148
async function make_data() {
130-
const response = await getJson<DashboardResponse>(DASHBOARD_DATA_URL);
149+
if (!response) {
150+
response = await getJson<DashboardResponse>(DASHBOARD_DATA_URL);
151+
}
152+
131153
populate_data(response);
132154
}
133155

site/frontend/templates/pages/dashboard.html

+11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424
compiled by a given version of the Rust compiler.
2525
</details>
2626

27+
<form id="scale-select-form">
28+
<label>
29+
<input type="radio" name="scale-select" value="linear" checked />
30+
Linear-scale
31+
</label>
32+
<label>
33+
<input type="radio" name="scale-select" value="log" />
34+
Log-scale
35+
</label>
36+
</form>
37+
2738
<div class="graphs">
2839
<div id="check-average-times"></div>
2940
<div id="debug-average-times"></div>

0 commit comments

Comments
 (0)