benchmark: output JSON-compatible numbers

This is to simplify the implementation of a JavaScript version of the
compare.R script.

PR-URL: https://github.com/nodejs/node/pull/38778
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
This commit is contained in:
Michaël Zasso authored and Danielle Adams committed 2021-05-31 15:34:54 -04:00
1 parent 6d86f8afd5
commit 4e58ec4aa6
1 file changed
+1 -1
+1 -1
View File
@@ -267,7 +267,7 @@ class Benchmark {
function nanoSecondsToString(bigint) {
const str = bigint.toString();
const decimalPointIndex = str.length - 9;
if (decimalPointIndex < 0) {
if (decimalPointIndex <= 0) {
return `0.${'0'.repeat(-decimalPointIndex)}${str}`;
}
return `${str.slice(0, decimalPointIndex)}.${str.slice(decimalPointIndex)}`;