Skip to content

Commit 66c2e4b

Browse files
committed
Add historical 30 day graph to benchmark detail
1 parent f84be89 commit 66c2e4b

File tree

4 files changed

+62
-10
lines changed

4 files changed

+62
-10
lines changed

site/frontend/src/pages/compare/compile/table/benchmark-detail.vue

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,34 @@ import {
55
CompileBenchmarkMetadata,
66
CompileTestCase,
77
} from "../common";
8-
import {computed} from "vue";
8+
import {computed, onMounted, Ref, ref} from "vue";
99
import Tooltip from "../../tooltip.vue";
10+
import {loadGraphs} from "../../../../graph/api";
11+
import {ArtifactDescription} from "../../types";
12+
import {getDateInPast} from "./utils";
13+
import {renderPlots} from "../../../../graph/render";
1014
1115
const props = defineProps<{
1216
testCase: CompileTestCase;
17+
metric: string;
18+
artifact: ArtifactDescription;
1319
benchmarkMap: CompileBenchmarkMap;
1420
}>();
21+
22+
async function renderGraph() {
23+
const selector = {
24+
benchmark: props.testCase.benchmark,
25+
profile: props.testCase.profile,
26+
scenario: props.testCase.scenario,
27+
stat: props.metric,
28+
start: getDateInPast(props.artifact),
29+
end: props.artifact.commit,
30+
kind: "raw",
31+
};
32+
const graphData = await loadGraphs(selector);
33+
renderPlots(graphData, selector, chartElement.value);
34+
}
35+
1536
const metadata = computed(
1637
(): CompileBenchmarkMetadata =>
1738
props.benchmarkMap[props.testCase.benchmark] ?? null
@@ -29,6 +50,10 @@ const cargoProfile = computed((): CargoProfileMetadata => {
2950
return metadata?.value.dev_profile;
3051
}
3152
});
53+
54+
const chartElement: Ref<HTMLElement | null> = ref(null);
55+
56+
onMounted(() => renderGraph());
3257
</script>
3358
<template>
3459
<table>
@@ -75,6 +100,7 @@ const cargoProfile = computed((): CargoProfileMetadata => {
75100
</tr>
76101
</tbody>
77102
</table>
103+
<div ref="chartElement"></div>
78104
</template>
79105

80106
<style scoped lang="scss">
@@ -89,3 +115,17 @@ table {
89115
}
90116
}
91117
</style>
118+
<style>
119+
.u-tooltip {
120+
font-size: 10pt;
121+
position: absolute;
122+
background: #fff;
123+
display: none;
124+
border: 2px solid black;
125+
padding: 4px;
126+
pointer-events: none;
127+
z-index: 100;
128+
white-space: pre;
129+
font-family: monospace;
130+
}
131+
</style>

site/frontend/src/pages/compare/compile/table/comparisons-table.vue

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {CompileBenchmarkMap, CompileTestCase} from "../common";
77
import {computed} from "vue";
88
import {useExpandedStore} from "./expansion";
99
import BenchmarkDetail from "./benchmark-detail.vue";
10+
import {getDateInPast} from "./utils";
1011
1112
const props = defineProps<{
1213
id: string;
@@ -28,15 +29,8 @@ function graphLink(
2829
stat: string,
2930
comparison: TestCaseComparison<CompileTestCase>
3031
): string {
31-
let date = new Date(commit.date);
32-
// Move to `30 days ago` to display history of the test case
33-
date.setUTCDate(date.getUTCDate() - 30);
34-
let year = date.getUTCFullYear();
35-
let month = (date.getUTCMonth() + 1).toString().padStart(2, "0");
36-
let day = date.getUTCDate().toString().padStart(2, "0");
37-
let start = `${year}-${month}-${day}`;
38-
39-
let end = commit.commit;
32+
const start = getDateInPast(commit);
33+
const end = commit.commit;
4034
const {benchmark, profile, scenario} = comparison.testCase;
4135
return `/index.html?start=${start}&end=${end}&benchmark=${benchmark}&profile=${profile}&scenario=${scenario}&stat=${stat}`;
4236
}
@@ -202,6 +196,8 @@ const {toggleExpanded, isExpanded} = useExpandedStore();
202196
<td :colspan="columnCount">
203197
<BenchmarkDetail
204198
:test-case="comparison.testCase"
199+
:artifact="commitB"
200+
:metric="stat"
205201
:benchmark-map="benchmarkMap"
206202
/>
207203
</td>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {ArtifactDescription} from "../../types";
2+
3+
/**
4+
* Returns a date in the past for which we want to display a historical chart.
5+
*/
6+
export function getDateInPast(artifact: ArtifactDescription): string {
7+
const date = new Date(artifact.date);
8+
// Move to `30 days ago` to display history of the test case
9+
date.setUTCDate(date.getUTCDate() - 30);
10+
const year = date.getUTCFullYear();
11+
const month = (date.getUTCMonth() + 1).toString().padStart(2, "0");
12+
const day = date.getUTCDate().toString().padStart(2, "0");
13+
return `${year}-${month}-${day}`;
14+
}

site/frontend/templates/pages/compare.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{% extends "layout.html" %}
22
{% block head %}
3+
<link rel="stylesheet" href="styles/uPlot.min.css">
4+
35
<style>
46
body {
57
max-width: 1000px;

0 commit comments

Comments
 (0)