Skip to content

Commit 9086b3f

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

File tree

3 files changed

+51
-16
lines changed

3 files changed

+51
-16
lines changed

site/frontend/src/pages/dashboard.ts

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
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(document.querySelectorAll<HTMLInputElement>(
10+
"#scale-select-form input",
11+
));
12+
13+
console.log(buttons);
14+
15+
Array.from(buttons).map((button) => {
16+
console.log("a");
17+
button.addEventListener("change", () => {
18+
console.log(button, "click");
19+
if (button.checked) {
20+
scale = button.value as ScaleKind;
21+
make_data();
22+
}
23+
});
24+
});
525

626
interface DashboardCompileBenchmarkCases {
727
clean_averages: [number];
@@ -27,9 +47,9 @@ function render(
2747
element: string,
2848
name: Profile,
2949
data: DashboardCompileBenchmarkCases,
30-
versions: [string]
50+
versions: [string],
3151
) {
32-
let articles = {check: "a", debug: "a", opt: "an", doc: "a"};
52+
let articles = { check: "a", debug: "a", opt: "an", doc: "a" };
3353

3454
Highcharts.chart({
3555
chart: {
@@ -43,13 +63,13 @@ function render(
4363
text: `Average time for ${articles[name]} ${name} build`,
4464
},
4565
yAxis: {
46-
title: {text: "Seconds"},
47-
min: Math.min(...Object.keys(data).flatMap((key) => data[key])),
48-
type: "logarithmic",
66+
title: { text: "Seconds" },
67+
min: scale === "linear" ? 0 : undefined,
68+
type: scale === "log" ? "logarithmic" : undefined,
4969
},
5070
xAxis: {
5171
categories: versions,
52-
title: {text: "Version"},
72+
title: { text: "Version" },
5373
},
5474
series: [
5575
{
@@ -100,13 +120,13 @@ function renderRuntime(element: string, data: [number], versions: [string]) {
100120
text: `Average time for a runtime benchmark`,
101121
},
102122
yAxis: {
103-
title: {text: "Miliseconds"},
104-
min: Math.min(...formattedData),
105-
type: "logarithmic",
123+
title: { text: "Miliseconds" },
124+
min: scale === "linear" ? 0 : undefined,
125+
type: scale === "log" ? "logarithmic" : undefined,
106126
},
107127
xAxis: {
108128
categories: versions.slice(nullCount),
109-
title: {text: "Version"},
129+
title: { text: "Version" },
110130
},
111131
series: [
112132
{

site/frontend/src/urls.ts

Lines changed: 8 additions & 4 deletions
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

@@ -7,7 +8,10 @@ export const STATUS_DATA_URL = `${BASE_URL}/status_page`;
78
export const BOOTSTRAP_DATA_URL = `${BASE_URL}/bootstrap`;
89
export const GRAPH_DATA_URL = `${BASE_URL}/graphs`;
910
export const COMPARE_DATA_URL = `${BASE_URL}/get`;
10-
export const COMPARE_COMPILE_DETAIL_GRAPHS_DATA_URL = `${BASE_URL}/compare-compile-detail-graphs`;
11-
export const COMPARE_RUNTIME_DETAIL_GRAPHS_DATA_URL = `${BASE_URL}/compare-runtime-detail-graphs`;
12-
export const COMPARE_COMPILE_DETAIL_SECTIONS_DATA_URL = `${BASE_URL}/compare-compile-detail-sections`;
11+
export const COMPARE_COMPILE_DETAIL_GRAPHS_DATA_URL =
12+
`${BASE_URL}/compare-compile-detail-graphs`;
13+
export const COMPARE_RUNTIME_DETAIL_GRAPHS_DATA_URL =
14+
`${BASE_URL}/compare-runtime-detail-graphs`;
15+
export const COMPARE_COMPILE_DETAIL_SECTIONS_DATA_URL =
16+
`${BASE_URL}/compare-compile-detail-sections`;
1317
export const SELF_PROFILE_DATA_URL = `${BASE_URL}/self-profile`;

site/frontend/templates/pages/dashboard.html

Lines changed: 11 additions & 0 deletions
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)