From c28295018d4c9f5cc3fd569f1ca26c8480aa05fb Mon Sep 17 00:00:00 2001 From: legendecas Date: Fri, 8 Jul 2022 02:02:21 +0800 Subject: [PATCH] benchmark: fix benchmark compare output --- benchmark/common.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/benchmark/common.js b/benchmark/common.js index e582dc8bdc219f..349684d986bbf2 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -261,6 +261,12 @@ class Benchmark { time: nanoSecondsToString(elapsed), type: 'report', }); + + // If, for any reason, the process is unable to self close within + // a second after completing, forcefully close it. + setTimeout(() => { + process.exit(0); + }, 5000).unref(); } } @@ -287,15 +293,9 @@ function formatResult(data) { } function sendResult(data) { - if (process.send && Object.hasOwn(process.env, 'NODE_RUN_BENCHMARK_FN')) { + if (process.send) { // If forked, report by process send - process.send(data, () => { - // If, for any reason, the process is unable to self close within - // a second after completing, forcefully close it. - setTimeout(() => { - process.exit(0); - }, 5000).unref(); - }); + process.send(data); } else { // Otherwise report by stdout process.stdout.write(formatResult(data));