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

Improve performance of toArrayLike #222

Merged
merged 6 commits into from
Aug 9, 2019

Conversation

fanatid
Copy link
Collaborator

@fanatid fanatid commented Jul 12, 2019

From 6x to 174x improvement. Was need turn off bignum, because node 12 not supported.

$ # old 768 bytes number
$ SEED=27af4987aa60091dc42b1314d340e8c0 node index.js toArray
Seed: 27af4987aa60091dc42b1314d340e8c0
Benchmarking: toArray
bn.js#toArray x 3,437 ops/sec ±7.94% (7 runs sampled)
------------------------
Fastest is bn.js#toArray
========================
$ # old 32 bytes number
$ SEED=27af4987aa60091dc42b1314d340e8c0 node index.js toArray
Seed: 27af4987aa60091dc42b1314d340e8c0
Benchmarking: toArray
bn.js#toArray x 947,728 ops/sec ±3.40% (9 runs sampled)
------------------------
Fastest is bn.js#toArray
========================
$ # new 768 bytes number
$ SEED=27af4987aa60091dc42b1314d340e8c0 node index.js toArray
Seed: 27af4987aa60091dc42b1314d340e8c0
Benchmarking: toArray
bn.js#toArray x 600,559 ops/sec ±3.99% (8 runs sampled)
------------------------
Fastest is bn.js#toArray
========================
$ # new 32 bytes number
$ SEED=27af4987aa60091dc42b1314d340e8c0 node index.js toArray
Seed: 27af4987aa60091dc42b1314d340e8c0
Benchmarking: toArray
bn.js#toArray x 6,293,522 ops/sec ±1.83% (8 runs sampled)
------------------------
Fastest is bn.js#toArray
========================

chjj added a commit to bcoin-org/bcrypto that referenced this pull request Aug 1, 2019
@fanatid fanatid merged commit b28644b into indutny:master Aug 9, 2019
@fanatid fanatid deleted the improve-toArrayLike branch August 9, 2019 21:22
@fanatid fanatid mentioned this pull request Dec 22, 2019
ivanshukhov pushed a commit to Kapoio/bn.js that referenced this pull request Jul 31, 2020
* add toArray to benchmark

* optimize BN#toArrayLike

* split BN#toArrayLike

* fix bounds in toArrayLike*

* add more tests for toArrayLike

* save 1 op in toArrayLike*

(cherry picked from commit b28644b)
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.

1 participant