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(encode): use Number.isInteger #23

Closed

Conversation

bengl
Copy link

@bengl bengl commented Oct 26, 2020

Number.isInteger is a faster operation than flooring a value and then checking it with isFinite.

| | tiny │ small │ medium │ large |
|--|--|--|--|--|
| before │ 2,659,084 ops/sec │ 579,367 ops/sec │ 46,217 ops/sec │ 488 ops/sec |
| after │ 2,784,261 ops/sec │ 618,960 ops/sec │ 46,302 ops/sec │ 480 ops/sec |

+----------------------------+-------------------+-----------------+----------------+---------------+
|                            │ tiny              │ small           │ medium         │ large         |
+----------------------------+-------------------+-----------------+----------------+---------------+
| after                      │ 2,659,084 ops/sec │ 579,367 ops/sec │ 46,217 ops/sec │ 488 ops/sec   |
+----------------------------+-------------------+-----------------+----------------+---------------+
| before                     │ 2,784,261 ops/sec │ 618,960 ops/sec │ 46,302 ops/sec │ 480 ops/sec   |
+----------------------------+-------------------+-----------------+----------------+---------------+
@zdm
Copy link

zdm commented Jan 15, 2021

Benchmarks says that Number.isInteger() is slower.

@darrachequesne
Copy link
Owner

Closed due to inactivity, please reopen if needed.

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.

None yet

3 participants