Skip to content

Performance Boost #8

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

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

Performance Boost #8

wants to merge 2 commits into from

Conversation

lukeed
Copy link

@lukeed lukeed commented Jul 16, 2018

Yo~!

This improves performance significantly on any number slicing or parsing. It also defaults any NaN-derived value to 1, the default.

I also included a simple solution to #7.

Custom benchmarks were setup as the current ones seem to be outdated & I couldn't get them to work =/ These were made with benchmark.js and your randomatic lib for fixtures. I can PR this as well if you're interested.

Before

# Last Item (1000)
  array-last x 167,157,582 ops/sec ±0.16% (97 runs sampled)

# Last Item (1000000)
  array-last x 166,438,057 ops/sec ±0.58% (95 runs sampled)

# Last 10 Items (1000)
  array-last x 29,290,764 ops/sec ±0.25% (95 runs sampled)

# Last 10 Items (1000000)
  array-last x 29,418,958 ops/sec ±0.28% (96 runs sampled)

# Last "10" Items (1000)
  array-last x 17,594,653 ops/sec ±0.76% (98 runs sampled)

# Last "10" Items (1000000)
  array-last x 17,747,237 ops/sec ±1.69% (96 runs sampled)

# Last N+1 Items (1000)
  array-last x 921 ops/sec ±0.14% (96 runs sampled)

# Last N+1 Items (1000000)
  array-last x 74.02 ops/sec ±3.78% (64 runs sampled)

After

# Last Item (1000)
  array-last x 167,646,149 ops/sec ±0.18% (95 runs sampled)

# Last Item (1000000)
  array-last x 167,290,607 ops/sec ±0.62% (94 runs sampled)

# Last 10 Items (1000)
  array-last x 35,060,211 ops/sec ±0.59% (90 runs sampled)

# Last 10 Items (1000000)
  array-last x 35,672,206 ops/sec ±0.21% (98 runs sampled)

# Last "10" Items (1000)
  array-last x 23,583,987 ops/sec ±0.82% (92 runs sampled)

# Last "10" Items (1000000)
  array-last x 23,344,110 ops/sec ±1.93% (98 runs sampled)

# Last N+1 Items (1000)
  array-last x 132,743,603 ops/sec ±0.34% (96 runs sampled)

# Last N+1 Items (1000000)
  array-last x 132,547,623 ops/sec ±0.62% (95 runs sampled)

@phated
Copy link
Collaborator

phated commented Sep 22, 2020

I dig this. I think it would be great to have the benchmarks and a test for the fix you added.

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