Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: improve performance of emit() #70

Merged
merged 1 commit into from
Dec 4, 2022
Merged

perf: improve performance of emit() #70

merged 1 commit into from
Dec 4, 2022

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Dec 4, 2022

Follow Up of #69

As @climba03003 correctly concluded, checking first if we already emitted the warning is actually the performance gain. So we put that to the fast-path.

before:

uzlopak@Battlestation:~/workspace/fastify-org/process-warning$ node benchmarks/warn.js
warn x 40,120,473 ops/sec ±0.64% (98 runs sampled)
(node:9821) [FST_ERROR_CODE_1] FastifyWarning: message
(Use `node --trace-warnings ...` to show where the warning was created)
(node:9821) [FST_ERROR_CODE_3] FastifyWarning: message

after:

uzlopak@Battlestation:~/workspace/fastify-org/process-warning$ node benchmarks/warn.js
warn x 90,812,134 ops/sec ±0.27% (94 runs sampled)
(node:9882) [FST_ERROR_CODE_1] FastifyWarning: message
(Use `node --trace-warnings ...` to show where the warning was created)
(node:9882) [FST_ERROR_CODE_3] FastifyWarning: message

Checklist

@Uzlopak Uzlopak mentioned this pull request Dec 4, 2022
4 tasks
@Uzlopak Uzlopak requested a review from mcollina December 4, 2022 21:40
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Uzlopak Uzlopak merged commit 005053d into master Dec 4, 2022
@Uzlopak Uzlopak deleted the perf-optimize branch December 4, 2022 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants