Skip to content

Commit 7889416

Browse files
committed
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: #10559 Reviewed-By: James M Snell <[email protected]>
1 parent f955c73 commit 7889416

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

benchmark/common.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,9 @@ function formatResult(data) {
195195
conf += ' ' + key + '=' + JSON.stringify(data.conf[key]);
196196
}
197197

198-
const rate = Math.floor(data.rate)
199-
.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
198+
var rate = data.rate.toString().split('.');
199+
rate[0] = rate[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
200+
rate = (rate[1] ? rate.join('.') : rate[0]);
200201
return `${data.name}${conf}: ${rate}`;
201202
}
202203

benchmark/run.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ if (format === 'csv') {
5656
conf = conf.replace(/"/g, '""');
5757
console.log(`"${data.name}", "${conf}", ${data.rate}, ${data.time}`);
5858
} else {
59-
const rate = Math.floor(data.rate)
60-
.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
59+
var rate = data.rate.toString().split('.');
60+
rate[0] = rate[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
61+
rate = (rate[1] ? rate.join('.') : rate[0]);
6162
console.log(`${data.name} ${conf}: ${rate}`);
6263
}
6364
});

0 commit comments

Comments
 (0)