Skip to content

Commit fc567d9

Browse files
committed
Record for each received message, not for the whole batch.
1 parent eb1dc8f commit fc567d9

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

anger.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ function anger (opts) {
6464
const mapObj = map.get(uidOf(payload))
6565
totalResponses++
6666

67+
const startTime = mapObj.start
68+
const end = process.hrtime(startTime)
69+
const responseTime = end[0] * 1e3 + end[1] / 1e6
70+
latencies.record(responseTime)
71+
6772
if (!--mapObj.expectedResponses) {
6873
tracker.emit('publish-events-recieved', uidOf(payload))
6974

@@ -73,11 +78,6 @@ function anger (opts) {
7378

7479
return next(mapObj.sender)
7580
}
76-
77-
const startTime = mapObj.start
78-
const end = process.hrtime(startTime)
79-
const responseTime = end[0] * 1e3 + end[1] / 1e6
80-
latencies.record(responseTime)
8181
}
8282

8383
function next (sender) {

examples/benchmark.js

+1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ const instance = anger({
2525

2626
instance.on('end', (result) => {
2727
// do things with result! yay!
28+
console.log(result)
2829
})

0 commit comments

Comments
 (0)