Skip to content

Improve performance of toArrayLike#222

Merged
fanatid merged 6 commits intoindutny:masterfrom
fanatid:improve-toArrayLike
Aug 9, 2019
Merged

Improve performance of toArrayLike#222
fanatid merged 6 commits intoindutny:masterfrom
fanatid:improve-toArrayLike

Conversation

@fanatid
Copy link
Copy Markdown
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 force-pushed the improve-toArrayLike branch from fbba685 to 791750a Compare August 9, 2019 20:32
@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