darrachequesne / notepack

A fast Node.js implementation of the latest MessagePack spec
MIT License
75 stars 19 forks source link

perf(encode): use Number.isInteger #23

Closed bengl closed 3 years ago

bengl commented 3 years ago

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
zdm commented 3 years ago

Benchmarks says that Number.isInteger() is slower.

darrachequesne commented 3 years ago

Closed due to inactivity, please reopen if needed.