@@ -263,24 +263,37 @@ async function runBenchFile(file : string, options : BenchOptions, replica : Ben
263
263
264
264
let getTable = ( prop : keyof BenchResult ) : string => {
265
265
let resArr = [ [ '' , ...schema . cols ] ] ;
266
+ let allZero = true ;
266
267
267
268
for ( let [ _rowIndex , row ] of schema . rows . entries ( ) ) {
268
269
let curRow = [ row ] ;
269
270
270
271
for ( let [ _colIndex , col ] of schema . cols . entries ( ) ) {
271
272
let res = results . get ( `${ row } :${ col } ` ) ;
272
273
if ( res ) {
274
+ if ( res [ prop ] != 0n ) {
275
+ allZero = false ;
276
+ }
273
277
274
278
// compare with previous results
275
279
let diff = '' ;
276
280
if ( options . compare && prevResults ) {
277
281
let prevRes = prevResults . get ( `${ row } :${ col } ` ) ;
278
282
if ( prevRes ) {
279
283
let percent = ( Number ( res [ prop ] ) - Number ( prevRes [ prop ] ) ) / Number ( prevRes [ prop ] ) * 100 ;
284
+ if ( Object . is ( percent , NaN ) ) {
285
+ percent = 0 ;
286
+ }
280
287
let sign = percent > 0 ? '+' : '' ;
281
288
let percentText = percent == 0 ? '0%' : sign + percent . toFixed ( 2 ) + '%' ;
282
289
let color : keyof typeof chalk = percent == 0 ? 'gray' : ( percent > 0 ? 'red' : 'green' ) ;
283
- diff = ` (${ chalk [ color ] ( percentText ) } )` ;
290
+ if ( process . env . CI ) {
291
+ // diff = ` (<span style="color:${color}">${percentText}</span>)`;
292
+ diff = ` (\${\\color{${ color } }${ percentText . replace ( '%' , '\\\\%' ) } }$)` ;
293
+ }
294
+ else {
295
+ diff = ` (${ chalk [ color ] ( percentText ) } )` ;
296
+ }
284
297
}
285
298
else {
286
299
diff = chalk . yellow ( ' (no previous results)' ) ;
@@ -307,6 +320,11 @@ async function runBenchFile(file : string, options : BenchOptions, replica : Ben
307
320
resArr . push ( curRow ) ;
308
321
}
309
322
323
+ // don't show Stable Memory table if all values are 0
324
+ if ( allZero && prop == 'rts_logical_stable_memory_size' ) {
325
+ return '' ;
326
+ }
327
+
310
328
return markdownTable ( resArr , {
311
329
align : [ 'l' , ...'r' . repeat ( schema . cols . length ) ] ,
312
330
stringLength : stringWidth ,
@@ -322,7 +340,7 @@ async function runBenchFile(file : string, options : BenchOptions, replica : Ben
322
340
\n\n${ chalk . blue ( 'Instructions' ) } \n\n${ getTable ( 'instructions' ) }
323
341
\n\n${ chalk . blue ( 'Heap' ) } \n\n${ getTable ( 'rts_heap_size' ) }
324
342
\n\n${ chalk . blue ( 'Garbage Collection' ) } \n\n${ getTable ( 'rts_reclaimed' ) }
325
- \n\n${ chalk . blue ( 'Stable Memory' ) } \n\n${ getTable ( 'rts_logical_stable_memory_size' ) }
343
+ ${ getTable ( 'rts_logical_stable_memory_size' ) ? ` \n\n${ chalk . blue ( 'Stable Memory' ) } \n\n${ getTable ( 'rts_logical_stable_memory_size' ) } ` : '' }
326
344
` ;
327
345
} ;
328
346
0 commit comments