@@ -35,13 +35,24 @@ function calculate_width(value: number, totalDuration: number): string {
3535 return ` ${(fraction * 100 ).toFixed (2 )}% ` ;
3636}
3737
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+
3849function formatPercent(
3950 sections : CompilationSections ,
4051 sectionName : string
4152): 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 ;
4556 const total = calculateTotalSectionsDuration (sections );
4657 const percent = (value / total ) * 100 ;
4758 return ` ${percent .toFixed (2 )}% ` ;
@@ -107,8 +118,19 @@ function deactivate() {
107118 <b >{{ section.name }}</b >
108119 </div >
109120 <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 >
112134 </div >
113135 </div >
114136 </div >
0 commit comments