Skip to content

Commit

Permalink
add performance measurement
Browse files Browse the repository at this point in the history
  • Loading branch information
malteish committed Sep 5, 2024
1 parent fd24448 commit 228620e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/delivery-service/src/rpc/methods/handleSubmitMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,27 @@ export async function handleSubmitMessage(
);

try {
const startTime = performance.now();
await messageProcessor.processEnvelop(envelop);

const middleTime = performance.now();
await db.countMessage(
getEnvelopSize(envelop),
deliveryServiceProperties,
);
const endTime = performance.now();
const durationCountMessage = endTime - middleTime;
const durationMessageProcessor = middleTime - startTime;
console.log(
`db.countMessage took ${durationCountMessage.toFixed(
2,
)} milliseconds, messageProcessor took ${durationMessageProcessor.toFixed(
2,
)} milliseconds. Total time: ${
durationCountMessage + durationMessageProcessor
} milliseconds`,
);

res.sendStatus(200);
} catch (error) {
console.error('handle submit message error');
Expand Down

0 comments on commit 228620e

Please sign in to comment.