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(utils): fast prepareValue #3370

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

cesco69
Copy link
Contributor

@cesco69 cesco69 commented Feb 6, 2025

This PR add a performance improvements at prepareValue for non-object value by skipping useless condition

On number/string/boolean

Master 357,250 ops/s
PR     740,050 ops/s

On object/array/date/buffer

Master 274,180 ops/s
PR     241,150 ops/s

Benchmark

This PR add a performance improvements at prepare Value for non-object by skipping useless condition
Copy link
Collaborator

@charmander charmander left a comment

Choose a reason for hiding this comment

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

I can’t reproduce those benchmark numbers with that link. Microbenchmarks can be misleading and that website seems unreliable. Like #3372, it’s fine as just cleanup anyway, though.

Comment on lines -48 to -51
// null and undefined are both null for postgres
if (val == null) {
return null
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer preserving this for readability and to avoid having to check typeof val === 'undefined'.

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