@@ -174,20 +174,21 @@ function displayMetrics() {
174174 Object . entries ( performanceElements ) . forEach ( ( [ elementId , value ] ) => {
175175 const element = document . getElementById ( elementId ) ;
176176 if ( element ) {
177- element . textContent = `${ value } %` ;
177+ // Ensure value is treated as a number before calling toFixed
178+ element . textContent = `${ Number ( value ) . toFixed ( 2 ) } %` ;
178179 element . classList . remove ( 'positive' , 'negative' ) ;
179180 element . classList . add ( value > 0 ? 'positive' : 'negative' ) ;
180181 }
181182 } ) ;
182183
183184 // Update executive summary values - safely handle potentially missing elements
184185 const executiveSummaryUpdates = {
185- 'apiCallsReduction' : - parseFloat ( improvements . calls ) . toFixed ( 1 ) ,
186- 'interactionsReduction' : - parseFloat ( improvements . interactions ) . toFixed ( 1 ) ,
187- 'successImprovement' : parseFloat ( improvements . success ) . toFixed ( 1 ) ,
188- 'tokenIncrease' : parseFloat ( improvements . tokens ) . toFixed ( 1 ) ,
189- 'costIncrease' : parseFloat ( improvements . cost ) . toFixed ( 1 ) ,
190- 'cacheWritesIncrease' : parseFloat ( improvements . cacheWrites ) . toFixed ( 1 )
186+ 'apiCallsReduction' : ( - parseFloat ( improvements . calls ) ) . toFixed ( 2 ) ,
187+ 'interactionsReduction' : ( - parseFloat ( improvements . interactions ) ) . toFixed ( 2 ) ,
188+ 'successImprovement' : ( parseFloat ( improvements . success ) ) . toFixed ( 2 ) ,
189+ 'tokenIncrease' : ( parseFloat ( improvements . tokens ) ) . toFixed ( 2 ) ,
190+ 'costIncrease' : ( parseFloat ( improvements . cost ) ) . toFixed ( 2 ) ,
191+ 'cacheWritesIncrease' : ( parseFloat ( improvements . cacheWrites ) ) . toFixed ( 2 )
191192 } ;
192193
193194 Object . entries ( executiveSummaryUpdates ) . forEach ( ( [ elementId , value ] ) => {
@@ -211,11 +212,11 @@ function displayMetrics() {
211212 <div class="metric-unit">Measured in ${ values . unit } </div>
212213 <div class="metric-value">
213214 <span class="mode">Control:</span>
214- <span>${ values . control . toFixed ( 1 ) } ${ title . includes ( 'Rate' ) ? '%' : '' } </span>
215+ <span>${ values . control . toFixed ( 2 ) } ${ title . includes ( 'Rate' ) ? '%' : '' } </span>
215216 </div>
216217 <div class="metric-value">
217218 <span class="mode">MCP:</span>
218- <span>${ values . mcp . toFixed ( 1 ) } ${ title . includes ( 'Rate' ) ? '%' : '' } </span>
219+ <span>${ values . mcp . toFixed ( 2 ) } ${ title . includes ( 'Rate' ) ? '%' : '' } </span>
219220 </div>
220221 <div class="metric-value">
221222 <span class="mode">Change:</span>
@@ -343,9 +344,9 @@ function displayModelMetrics() {
343344 <div class="compact-metric-title">${ title } </div>
344345 <div class="compact-metric-content">
345346 <div class="compact-metric-label">Control:</div>
346- <div class="compact-metric-value">${ values . control . toFixed ( 1 ) } ${ title . includes ( 'Rate' ) ? '%' : '' } </div>
347+ <div class="compact-metric-value">${ values . control . toFixed ( 2 ) } ${ title . includes ( 'Rate' ) ? '%' : '' } </div>
347348 <div class="compact-metric-label">MCP:</div>
348- <div class="compact-metric-value">${ values . mcp . toFixed ( 1 ) } ${ title . includes ( 'Rate' ) ? '%' : '' } </div>
349+ <div class="compact-metric-value">${ values . mcp . toFixed ( 2 ) } ${ title . includes ( 'Rate' ) ? '%' : '' } </div>
349350 <div class="compact-metric-label">Change:</div>
350351 <div class="compact-metric-value ${ changeClass } ">${ change } %</div>
351352 </div>
@@ -398,7 +399,7 @@ function displaySessions() {
398399 <td>Task ${ s . taskId } </td>
399400 <td><span class="badge badge-${ s . mode } ">${ s . mode } </span></td>
400401 <td><strong>${ s . model || 'Unknown' } </strong></td>
401- <td>${ ( s . duration / 1000 ) . toFixed ( 1 ) } </td>
402+ <td>${ ( s . duration / 1000 ) . toFixed ( 2 ) } </td>
402403 <td>${ s . apiCalls } </td>
403404 <td>${ s . interactions } </td>
404405 <td>${ s . totalTokens || 0 } </td>
@@ -657,7 +658,7 @@ function downloadCsv() {
657658 s . taskId ,
658659 s . mode ,
659660 s . model || 'unknown' ,
660- ( s . duration / 1000 ) . toFixed ( 1 ) ,
661+ ( s . duration / 1000 ) . toFixed ( 2 ) ,
661662 s . apiCalls ,
662663 s . interactions ,
663664 s . totalTokens || 0 ,
@@ -691,7 +692,9 @@ function percentage(part, total) {
691692}
692693
693694function percentageChange ( newValue , oldValue ) {
694- return oldValue ? ( ( ( newValue - oldValue ) / oldValue ) * 100 ) . toFixed ( 1 ) : 'N/A' ;
695+ if ( ! oldValue ) return 'N/A' ;
696+ const result = ( ( newValue - oldValue ) / oldValue ) * 100 ;
697+ return result . toFixed ( 2 ) ;
695698}
696699
697700// Event listeners
0 commit comments