diff options
author | Brian White <mscdex@mscdex.net> | 2016-12-31 21:50:25 -0500 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2017-01-05 02:48:07 -0500 |
commit | 7889416b8a93b70fbc1ebfe65b8918f84216c347 (patch) | |
tree | 394ead5c99d1fd7a5c43f077e95fb453d58131e1 | |
parent | f955c734bac29a5df3d8ebf45944abfeed5e929b (diff) | |
download | android-node-v8-7889416b8a93b70fbc1ebfe65b8918f84216c347.tar.gz android-node-v8-7889416b8a93b70fbc1ebfe65b8918f84216c347.tar.bz2 android-node-v8-7889416b8a93b70fbc1ebfe65b8918f84216c347.zip |
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>
-rw-r--r-- | benchmark/common.js | 5 | ||||
-rw-r--r-- | benchmark/run.js | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/benchmark/common.js b/benchmark/common.js index 9e7253504f..4ce9501dd9 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -195,8 +195,9 @@ function formatResult(data) { conf += ' ' + key + '=' + JSON.stringify(data.conf[key]); } - const rate = Math.floor(data.rate) - .toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); + var rate = data.rate.toString().split('.'); + rate[0] = rate[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); + rate = (rate[1] ? rate.join('.') : rate[0]); return `${data.name}${conf}: ${rate}`; } diff --git a/benchmark/run.js b/benchmark/run.js index 52ce74024e..1984066228 100644 --- a/benchmark/run.js +++ b/benchmark/run.js @@ -56,8 +56,9 @@ if (format === 'csv') { conf = conf.replace(/"/g, '""'); console.log(`"${data.name}", "${conf}", ${data.rate}, ${data.time}`); } else { - const rate = Math.floor(data.rate) - .toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); + var rate = data.rate.toString().split('.'); + 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}`); } }); |