From b8ccf30ac17a4ba7467f650af41fcc6f417ce6bd Mon Sep 17 00:00:00 2001 From: dnlup Date: Fri, 20 Dec 2019 18:14:16 +0100 Subject: [PATCH] benchmark: replace var with let/const in cluster benchmark PR-URL: https://github.com/nodejs/node/pull/31042 Reviewed-By: Ruben Bridgewater Reviewed-By: Rich Trott --- benchmark/cluster/echo.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/benchmark/cluster/echo.js b/benchmark/cluster/echo.js index 152f2c42f10f2b..9def87cf8b0e98 100644 --- a/benchmark/cluster/echo.js +++ b/benchmark/cluster/echo.js @@ -19,10 +19,10 @@ if (cluster.isMaster) { serialization }) { const expectedPerBroadcast = sendsPerBroadcast * workers; - var readies = 0; - var broadcasts = 0; - var msgCount = 0; - var data; + let readies = 0; + let broadcasts = 0; + let msgCount = 0; + let data; cluster.settings.serialization = serialization; @@ -37,7 +37,7 @@ if (cluster.isMaster) { throw new Error('Unsupported payload type'); } - for (var i = 0; i < workers; ++i) + for (let i = 0; i < workers; ++i) cluster.fork().on('online', onOnline).on('message', onMessage); function onOnline() { @@ -48,16 +48,15 @@ if (cluster.isMaster) { } function broadcast() { - var id; if (broadcasts++ === n) { bench.end(n); - for (id in cluster.workers) + for (const id in cluster.workers) cluster.workers[id].disconnect(); return; } - for (id in cluster.workers) { + for (const id in cluster.workers) { const worker = cluster.workers[id]; - for (var i = 0; i < sendsPerBroadcast; ++i) + for (let i = 0; i < sendsPerBroadcast; ++i) worker.send(data); } }