Skip to content

Commit 4d01542

Browse files
committed
perf: measure command latency
1 parent 12411da commit 4d01542

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/components/events/message.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export default async function (msg: Message, type: string): Promise<void> {
4545
if (!commandPrefixLess && prefix) return;
4646
if (msg.fromMe && prefix) return;
4747

48+
const receivedAt = Date.now();
49+
4850
/*
4951
* Block users from running commands.
5052
* will always return false if its admin
@@ -199,7 +201,9 @@ export default async function (msg: Message, type: string): Promise<void> {
199201
options?: MessageSendOptions,
200202
): Promise<Message> => {
201203
let messageBody = typeof content === "string" ? Font(content) : content;
202-
log.info("Reply", lid, key);
204+
const latency = Date.now() - receivedAt;
205+
const latencySec = (latency / 1000).toFixed(2);
206+
log.info("Reply", lid, `${key} ${latencySec}s`);
203207

204208
if (!msg.fromMe) {
205209
const chat = await msg.getChat();

0 commit comments

Comments
 (0)