Skip to content
Permalink
Browse files

benchmark: replace var with let/const in cluster benchmark

PR-URL: #31042
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
dnlup authored and Trott committed Dec 20, 2019
1 parent 51aca6d commit 3cec1a29696a9d72f97c3fb9f9a84f4da741f98f
Showing with 8 additions and 9 deletions.
  1. +8 −9 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);
}
}

0 comments on commit 3cec1a2

Please sign in to comment.
You can’t perform that action at this time.