Browse Source
benchmark: keep decimals in results
Some benchmarks' results are small values, so keeping decimals when
running them manually (not comparing) can be helpful.
PR-URL: https://github.com/nodejs/node/pull/10559
Reviewed-By: James M Snell <jasnell@gmail.com>
v6
Brian White
8 years ago
No known key found for this signature in database
GPG Key ID: 606D7358F94DA209
2 changed files with
6 additions and
4 deletions
benchmark/common.js
benchmark/run.js
@ -195,8 +195,9 @@ function formatResult(data) {
conf += ' ' + key + '=' + JSON . stringify ( data . conf [ key ] ) ;
conf += ' ' + key + '=' + JSON . stringify ( data . conf [ key ] ) ;
}
}
const rate = Math . floor ( data . rate )
var rate = data . rate . toString ( ) . split ( '.' ) ;
. toString ( ) . replace ( /(\d)(?=(\d\d\d)+(?!\d))/g , '$1,' ) ;
rate [ 0 ] = rate [ 0 ] . replace ( /(\d)(?=(\d\d\d)+(?!\d))/g , '$1,' ) ;
rate = ( rate [ 1 ] ? rate . join ( '.' ) : rate [ 0 ] ) ;
return ` ${ data . name } ${ conf } : ${ rate } ` ;
return ` ${ data . name } ${ conf } : ${ rate } ` ;
}
}
@ -56,8 +56,9 @@ if (format === 'csv') {
conf = conf . replace ( /"/g , '""' ) ;
conf = conf . replace ( /"/g , '""' ) ;
console . log ( ` " ${ data . name } ", " ${ conf } ", ${ data . rate } , ${ data . time } ` ) ;
console . log ( ` " ${ data . name } ", " ${ conf } ", ${ data . rate } , ${ data . time } ` ) ;
} else {
} else {
const rate = Math . floor ( data . rate )
var rate = data . rate . toString ( ) . split ( '.' ) ;
. toString ( ) . replace ( /(\d)(?=(\d\d\d)+(?!\d))/g , '$1,' ) ;
rate [ 0 ] = rate [ 0 ] . replace ( /(\d)(?=(\d\d\d)+(?!\d))/g , '$1,' ) ;
rate = ( rate [ 1 ] ? rate . join ( '.' ) : rate [ 0 ] ) ;
console . log ( ` ${ data . name } ${ conf } : ${ rate } ` ) ;
console . log ( ` ${ data . name } ${ conf } : ${ rate } ` ) ;
}
}
} ) ;
} ) ;