From 10b3297e8f4b98ccef00eff10f0edbe769da7fae Mon Sep 17 00:00:00 2001 From: Brian White Date: Tue, 20 Dec 2016 14:57:28 -0500 Subject: [PATCH] benchmark: use commas in non-csv rate output PR-URL: https://github.com/nodejs/node/pull/10360 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- benchmark/common.js | 4 +++- benchmark/run.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/benchmark/common.js b/benchmark/common.js index 94f11a2be96933..1ab734222a0498 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -185,7 +185,9 @@ function formatResult(data) { conf += ' ' + key + '=' + JSON.stringify(data.conf[key]); } - return `${data.name}${conf}: ${data.rate}`; + const rate = Math.floor(data.rate) + .toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); + return `${data.name}${conf}: ${rate}`; } function sendResult(data) { diff --git a/benchmark/run.js b/benchmark/run.js index 16e620f9a0db7b..52ce74024e1ae4 100644 --- a/benchmark/run.js +++ b/benchmark/run.js @@ -56,7 +56,9 @@ if (format === 'csv') { conf = conf.replace(/"/g, '""'); console.log(`"${data.name}", "${conf}", ${data.rate}, ${data.time}`); } else { - console.log(`${data.name} ${conf}: ${data.rate}`); + const rate = Math.floor(data.rate) + .toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); + console.log(`${data.name} ${conf}: ${rate}`); } });