danocmx / node-tf2-item-format

Fully typed battle-tested library that helps you format TF2 items to the community standards.
MIT License
24 stars 4 forks source link

Optimize isNumber util func #268

Closed piman51277 closed 1 year ago

piman51277 commented 1 year ago

Summary

Optimize the isNumber function for a general performance improvement.

Rationale

Why this works:

Why do we need this?

Benchmarks

Ran on i7-1360P on Debian 12.0 Benchmark performed using benchmark library

parseEconItem

original x 15,778 ops/sec ±0.60% (96 runs sampled)
optimized x 18,380 ops/sec ±0.53% (94 runs sampled)
Fastest is optimized

In repeated tests, this has shown a 10-15% speedup in execution time

danocmx commented 1 year ago

Can you replace the PR specific comment with a shortened version and cast the string to number instead of @ts-expect-error?

piman51277 commented 1 year ago

I have done that.

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 5.9.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: