Skip to content

Commit

Permalink
enhance bench req/rep (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
aricart committed Aug 16, 2023
1 parent 6d1a993 commit 0ac8abf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/bench.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ <h3>Test</h3>
<label><input class="form-check-input" type="radio" value="sub" id="sub" name="test">Subscribe</label>
</div>
<div class="radio-inline">
<label><input class="form-check-input" type="radio" value="sub" id="req" name="test">ReqRep</label>
<label><input class="form-check-input" type="radio" value="sub" id="reqrep" name="test">ReqReq</label>
</div>


<br/><br/>
<button id="send" onclick="benchapp.run()" class="btn btn-primary">Start</button>
</div>
Expand Down
21 changes: 18 additions & 3 deletions examples/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function getTestChoice() {
return "pub";
} else if (isChecked("sub")) {
return "sub";
} else if (isChecked("req")) {
return "req";
} else if (isChecked("reqrep")) {
return "reqrep";
}
}

Expand Down Expand Up @@ -73,7 +73,8 @@ async function run() {
t.subject = getString("subject");
t.pub = kind === "pub" || kind === "pubsub";
t.sub = kind === "sub" || kind === "pubsub";
t.req = kind === "req";
t.req = kind === "reqrep";
t.rep = kind === "reqrep";

const bench = new Bench(nc, t);
const m = await bench.run();
Expand All @@ -85,6 +86,10 @@ async function run() {
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 @@ -97,12 +102,19 @@ async function run() {
reducer,
new Metric("req", 0),
);
const rep = metrics.filter((m) => m.name === "rep").reduce(
reducer,
new Metric("rep", 0),
);

const report = [];

if (pubsub && pubsub.msgs) {
report.push(pubsub.toString());
}
if (reqrep && reqrep.msgs) {
report.push(reqrep.toString());
}
if (pub && pub.msgs) {
report.push(pub.toString());
}
Expand All @@ -112,6 +124,9 @@ async function run() {
if (req && req.msgs) {
report.push(req.toString());
}
if (rep && rep.msgs) {
report.push(rep.toString());
}
updateResults(report.join("\n"));
}

Expand Down

0 comments on commit 0ac8abf

Please sign in to comment.