Skip to content

Commit

Permalink
benchmark: replace var with let/const in cluster benchmark
Browse files Browse the repository at this point in the history
PR-URL: #31042
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
dnlup authored and BridgeAR committed Jan 3, 2020
1 parent 990760e commit b8ccf30
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions benchmark/cluster/echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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() {
Expand All @@ -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);
}
}
Expand Down

0 comments on commit b8ccf30

Please sign in to comment.