From ff1ac369bed09295f25b3b54c6e071ebce574bd4 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 5 Feb 2018 19:49:50 +0100 Subject: [PATCH 1/2] benchmark: improve compare output The current output uses JSON.stringify to escape the config values. This switches to util.inspect to have a better readable output. --- benchmark/compare.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/benchmark/compare.js b/benchmark/compare.js index 6b51a70eb9a41b..bdab63346f3641 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -1,6 +1,7 @@ 'use strict'; -const fork = require('child_process').fork; +const { fork } = require('child_process'); +const { inspect } = require('util'); const path = require('path'); const CLI = require('./_cli.js'); const BenchmarkProgress = require('./_benchmark_progress.js'); @@ -76,11 +77,9 @@ if (showProgress) { // Construct configuration string, " A=a, B=b, ..." let conf = ''; for (const key of Object.keys(data.conf)) { - conf += ` ${key}=${JSON.stringify(data.conf[key])}`; + conf += ` ${key}=${inspect(data.conf[key])}`; } conf = conf.slice(1); - // Escape quotes (") for correct csv formatting - conf = conf.replace(/"/g, '""'); console.log(`"${job.binary}", "${job.filename}", "${conf}", ` + `${data.rate}, ${data.time}`); From de425e244b205db482085c5f8994d81bba298813 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 6 Feb 2018 19:53:00 +0100 Subject: [PATCH 2/2] fixup: escape double quotes properly --- benchmark/compare.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/benchmark/compare.js b/benchmark/compare.js index bdab63346f3641..e7866b60e36418 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -80,6 +80,8 @@ if (showProgress) { conf += ` ${key}=${inspect(data.conf[key])}`; } conf = conf.slice(1); + // Escape quotes (") for correct csv formatting + conf = conf.replace(/"/g, '""'); console.log(`"${job.binary}", "${job.filename}", "${conf}", ` + `${data.rate}, ${data.time}`);