Skip to content

Commit d5bdcc9

Browse files
committed
add toggle between linear and log
1 parent 8f93b9b commit d5bdcc9

File tree

3 files changed

+41
-13
lines changed

3 files changed

+41
-13
lines changed

site/frontend/src/pages/dashboard.ts

+28-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
import Highcharts from "highcharts";
2-
import {DASHBOARD_DATA_URL} from "../urls";
2+
import { DASHBOARD_DATA_URL } from "../urls";
33

4-
import {getJson} from "../utils/requests";
4+
import { getJson } from "../utils/requests";
5+
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+
});
521

622
interface DashboardCompileBenchmarkCases {
723
clean_averages: [number];
@@ -27,9 +43,9 @@ function render(
2743
element: string,
2844
name: Profile,
2945
data: DashboardCompileBenchmarkCases,
30-
versions: [string]
46+
versions: [string],
3147
) {
32-
let articles = {check: "a", debug: "a", opt: "an", doc: "a"};
48+
let articles = { check: "a", debug: "a", opt: "an", doc: "a" };
3349

3450
Highcharts.chart({
3551
chart: {
@@ -43,13 +59,13 @@ function render(
4359
text: `Average time for ${articles[name]} ${name} build`,
4460
},
4561
yAxis: {
46-
title: {text: "Seconds"},
47-
min: Math.min(...Object.keys(data).flatMap((key) => data[key])),
48-
type: "logarithmic",
62+
title: { text: "Seconds" },
63+
min: scale === "linear" ? 0 : undefined,
64+
type: scale === "log" ? "logarithmic" : undefined,
4965
},
5066
xAxis: {
5167
categories: versions,
52-
title: {text: "Version"},
68+
title: { text: "Version" },
5369
},
5470
series: [
5571
{
@@ -100,13 +116,13 @@ function renderRuntime(element: string, data: [number], versions: [string]) {
100116
text: `Average time for a runtime benchmark`,
101117
},
102118
yAxis: {
103-
title: {text: "Miliseconds"},
104-
min: Math.min(...formattedData),
105-
type: "logarithmic",
119+
title: { text: "Miliseconds" },
120+
min: scale === "linear" ? 0 : undefined,
121+
type: scale === "log" ? "logarithmic" : undefined,
106122
},
107123
xAxis: {
108124
categories: versions.slice(nullCount),
109-
title: {text: "Version"},
125+
title: { text: "Version" },
110126
},
111127
series: [
112128
{

site/frontend/src/urls.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const BASE_URL = window.location.origin + "/perf";
1+
// const BASE_URL = window.location.origin + "/perf";
2+
const BASE_URL = "https://perf.rust-lang.org/perf";
23

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

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)