Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: use let and const instead of var in cluster #31042

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 8 additions & 9 deletions benchmark/cluster/echo.js
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