@@ -35,13 +35,24 @@ function calculate_width(value: number, totalDuration: number): string {
35
35
return ` ${(fraction * 100 ).toFixed (2 )}% ` ;
36
36
}
37
37
38
+ function getSectionByName(
39
+ sections : CompilationSections ,
40
+ name : string
41
+ ): CompilationSection | null {
42
+ const values = sections .sections .filter ((s ) => s .name === name );
43
+ if (values .length === 0 ) {
44
+ return null ;
45
+ }
46
+ return values [0 ];
47
+ }
48
+
38
49
function formatPercent(
39
50
sections : CompilationSections ,
40
51
sectionName : string
41
52
): string {
42
- const values = sections . sections . filter (( s ) => s . name === sectionName );
43
- if (values . length === 0 ) return " ??" ;
44
- const value = values [ 0 ] .value ;
53
+ const section = getSectionByName ( sections , sectionName );
54
+ if (section === null ) return " ??" ;
55
+ const value = section .value ;
45
56
const total = calculateTotalSectionsDuration (sections );
46
57
const percent = (value / total ) * 100 ;
47
58
return ` ${percent .toFixed (2 )}% ` ;
@@ -107,8 +118,19 @@ function deactivate() {
107
118
<b >{{ section.name }}</b >
108
119
</div >
109
120
<div >
110
- {{ formatPercent(props.before, section.name) }} ->
111
- {{ formatPercent(props.after, section.name) }}
121
+ <div >
122
+ {{ formatPercent(props.before, section.name) }} ->
123
+ {{ formatPercent(props.after, section.name) }}
124
+ </div >
125
+ <div >
126
+ {{
127
+ getSectionByName(props.before, section.name)?.value ?? "??"
128
+ }}
129
+ ->
130
+ {{
131
+ getSectionByName(props.after, section.name)?.value ?? "??"
132
+ }}
133
+ </div >
112
134
</div >
113
135
</div >
114
136
</div >
0 commit comments