Skip to content

Commit b5fff9c

Browse files
committed
Add compile section visualization
1 parent cb5979d commit b5fff9c

File tree

5 files changed

+177
-12
lines changed

5 files changed

+177
-12
lines changed

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

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ import {GraphRenderOpts, renderPlots} from "../../../../graph/render";
1313
import {GraphData, GraphKind, GraphsSelector} from "../../../../graph/data";
1414
import uPlot from "uplot";
1515
import CachegrindCmd from "../../../../components/cachegrind-cmd.vue";
16-
import {COMPILE_DETAIL_RESOLVER} from "./detail-resolver";
16+
import {
17+
CompilationSections,
18+
COMPILE_DETAIL_RESOLVER,
19+
CompileDetail,
20+
CompileDetailSelector,
21+
} from "./detail-resolver";
22+
import CompileSectionsChart from "./compile-sections-chart.vue";
23+
import {af} from "date-fns/locale";
1724
1825
const props = defineProps<{
1926
testCase: CompileTestCase;
@@ -96,10 +103,9 @@ function drawCurrentDate(opts: GraphRenderOpts, date: Date) {
96103
};
97104
}
98105
99-
// Render both relative and absolute graphs
100-
async function renderGraphs() {
101-
const {start, end, date} = graphRange.value;
102-
const selector = {
106+
function createSelector(): CompileDetailSelector {
107+
const {start, end} = graphRange.value;
108+
return {
103109
benchmark: props.testCase.benchmark,
104110
profile: props.testCase.profile,
105111
scenario: props.testCase.scenario,
@@ -108,7 +114,16 @@ async function renderGraphs() {
108114
end,
109115
kinds: ["percentrelative", "raw"] as GraphKind[],
110116
};
111-
const detail = await COMPILE_DETAIL_RESOLVER.loadDetail(selector);
117+
}
118+
119+
async function loadDetail(): Promise<CompileDetail> {
120+
return await COMPILE_DETAIL_RESOLVER.loadDetail(createSelector());
121+
}
122+
123+
// Render both relative and absolute graphs
124+
async function renderGraphs(detail: CompileDetail) {
125+
const selector = createSelector();
126+
const date = graphRange.value.date;
112127
if (detail.commits.length === 0) {
113128
return;
114129
}
@@ -261,7 +276,32 @@ function changeProfileCommand(event: Event) {
261276
profileCommand.value = target.value as ProfileCommand;
262277
}
263278
264-
onMounted(() => renderGraphs());
279+
/*
280+
* Calculates the longer titak duration out of the two passed compilation
281+
* section.
282+
*/
283+
function calculateTotalDuration(
284+
before: CompilationSections | null,
285+
after: CompilationSections | null
286+
): number {
287+
let beforeTotal = 0;
288+
if (before != null) {
289+
beforeTotal = before.frontend + before.backend + before.linker;
290+
}
291+
let afterTotal = 0;
292+
if (after != null) {
293+
afterTotal = after.frontend + after.backend + after.linker;
294+
}
295+
return Math.max(beforeTotal, afterTotal);
296+
}
297+
298+
const detail: Ref<CompileDetail | null> = ref(null);
299+
onMounted(() => {
300+
loadDetail().then((d) => {
301+
detail.value = d;
302+
renderGraphs(d);
303+
});
304+
});
265305
</script>
266306

267307
<template>
@@ -349,6 +389,39 @@ onMounted(() => renderGraphs());
349389
</li>
350390
</ul>
351391
</div>
392+
<div class="rows grow">
393+
<div class="title bold">
394+
Sections
395+
<Tooltip
396+
>Percentual duration of individual compilation sections (frontend,
397+
backend, linker)</Tooltip
398+
>
399+
</div>
400+
<div>
401+
<CompileSectionsChart
402+
v-if="(detail?.sections_before ?? null) !== null"
403+
label="Before"
404+
:sections="detail.sections_before"
405+
:total_duration="
406+
calculateTotalDuration(
407+
detail.sections_before,
408+
detail.sections_after
409+
)
410+
"
411+
/>
412+
<CompileSectionsChart
413+
v-if="(detail?.sections_after ?? null) !== null"
414+
label="After"
415+
:sections="detail.sections_after"
416+
:total_duration="
417+
calculateTotalDuration(
418+
detail.sections_before,
419+
detail.sections_after
420+
)
421+
"
422+
/>
423+
</div>
424+
</div>
352425
</div>
353426
<div class="columns graphs">
354427
<div class="rows center-items grow">

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +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 {getPastDate} from "./utils";
10+
import {prettifyRawNumber} from "./utils";
1111
1212
const props = defineProps<{
1313
id: string;
@@ -20,10 +20,6 @@ const props = defineProps<{
2020
stat: string;
2121
}>();
2222
23-
function prettifyRawNumber(number: number): string {
24-
return number.toLocaleString();
25-
}
26-
2723
const columnCount = computed(() => {
2824
const base = 7;
2925
if (props.showRawData) {
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<script setup lang="ts">
2+
import {CompilationSections} from "./detail-resolver";
3+
import {computed} from "vue";
4+
import {prettifyRawNumber} from "./utils";
5+
6+
const props = defineProps<{
7+
sections: CompilationSections;
8+
label: string;
9+
total_duration: number;
10+
}>();
11+
12+
const total = computed(
13+
() => props.sections.frontend + props.sections.backend + props.sections.linker
14+
);
15+
16+
function width(value: number): string {
17+
const fraction = value / props.total_duration;
18+
return `${(fraction * 100).toFixed(2)}%`;
19+
}
20+
function title(name: string, value: number): string {
21+
const percent = (value / total.value) * 100;
22+
return `${name}: ${percent.toFixed(2)}% (${prettifyRawNumber(value)})`;
23+
}
24+
</script>
25+
26+
<template>
27+
<div class="wrapper">
28+
<span class="label">{{ props.label }}</span>
29+
<div class="part-wrapper">
30+
<div
31+
class="part frontend"
32+
:title="title('Frontend', props.sections.frontend)"
33+
:style="{width: width(props.sections.frontend)}"
34+
></div>
35+
<div
36+
class="part backend"
37+
:title="title('Backend', props.sections.backend)"
38+
:style="{width: width(props.sections.backend)}"
39+
></div>
40+
<div
41+
class="part linker"
42+
:title="title('Linker', props.sections.linker)"
43+
:style="{width: width(props.sections.linker)}"
44+
></div>
45+
</div>
46+
</div>
47+
</template>
48+
49+
<style scoped lang="scss">
50+
.wrapper {
51+
display: flex;
52+
justify-content: flex-end;
53+
width: 300px;
54+
margin-bottom: 10px;
55+
}
56+
.label {
57+
margin-right: 5px;
58+
align-self: center;
59+
}
60+
.part-wrapper {
61+
width: 220px;
62+
display: flex;
63+
flex-direction: row;
64+
border-right: 1px dashed #333333;
65+
}
66+
.part {
67+
height: 30px;
68+
69+
&:hover {
70+
box-shadow: inset 0 0 1px 2px #000;
71+
}
72+
}
73+
.frontend {
74+
border-radius: 5px 0 0 5px;
75+
background-color: #ffcf96;
76+
}
77+
.backend {
78+
background-color: #ff8080;
79+
}
80+
.linker {
81+
border-radius: 0 5px 5px 0;
82+
background-color: #29adb2;
83+
}
84+
</style>

site/frontend/src/pages/compare/compile/table/detail-resolver.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,19 @@ export interface CompileDetailSelector {
1212
kinds: GraphKind[];
1313
}
1414

15+
export interface CompilationSections {
16+
frontend: number;
17+
backend: number;
18+
linker: number;
19+
}
20+
1521
// Compile benchmark detail received from the server
1622
export interface CompileDetail {
1723
commits: Array<[number, string]>;
1824
// One Series for each GraphKind in the CompileDetailSelector
1925
graphs: Series[];
26+
sections_before: CompilationSections | null;
27+
sections_after: CompilationSections | null;
2028
}
2129

2230
/**

site/frontend/src/pages/compare/compile/table/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ function format_ymd(date: Date): string {
2929
export function daysBetweenDates(a: Date, b: Date): number {
3030
return Math.floor((b.getTime() - a.getTime()) / (1000 * 60 * 60 * 24));
3131
}
32+
33+
export function prettifyRawNumber(number: number): string {
34+
return number.toLocaleString();
35+
}

0 commit comments

Comments
 (0)