Skip to content

Commit

Permalink
[FEAT] updated bench to match deno and allow req-reply
Browse files Browse the repository at this point in the history
  • Loading branch information
aricart committed Aug 15, 2023
1 parent 9a1016a commit 2da518e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion examples/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const argv = parse(
},
);

if (argv.h || argv.help || (!argv.sub && !argv.pub && !argv.req)) {
if (argv.h || argv.help || (!argv.sub && !argv.pub && !argv.req && !argv.rep)) {
console.log(
"usage: bench.ts [--json] [--callbacks] [--csv] [--csvheader] [--pub] [--sub] [--req (--asyncRequests)] [--count <#messages>=100000] [--payload <#bytes>=128] [--iterations <#loop>=1>] [--server server] [--subject <subj>]\n",
);
Expand All @@ -67,6 +67,7 @@ const metrics = [];
pub: argv.pub,
sub: argv.sub,
req: argv.req,
rep: argv.rep,
subject: argv.subject,
};

Expand Down Expand Up @@ -98,6 +99,10 @@ const metrics = [];
reducer,
new Metric("pubsub", 0),
);
const reqrep = metrics.filter((m) => m.name === "reqrep").reduce(
reducer,
new Metric("reqrep", 0),
);
const pub = metrics.filter((m) => m.name === "pub").reduce(
reducer,
new Metric("pub", 0),
Expand All @@ -110,10 +115,17 @@ const metrics = [];
reducer,
new Metric("req", 0),
);
const rep = metrics.filter((m) => m.name === "rep").reduce(
reducer,
new Metric("rep", 0),
);

if (pubsub && pubsub.msgs) {
console.log(pubsub.toString());
}
if (reqrep && reqrep.msgs) {
console.log(reqrep.toString());
}
if (pub && pub.msgs) {
console.log(pub.toString());
}
Expand All @@ -123,6 +135,9 @@ const metrics = [];
if (req && req.msgs) {
console.log(req.toString());
}
if (rep && rep.msgs) {
console.log(rep.toString());
}
} else if (argv.json) {
console.log(JSON.stringify(metrics, null, 2));
} else if (argv.csv) {
Expand Down

0 comments on commit 2da518e

Please sign in to comment.