Skip to content

Instantly share code, notes, and snippets.

@indutny
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indutny/7e520c440e2765a522a2 to your computer and use it in GitHub Desktop.
Save indutny/7e520c440e2765a522a2 to your computer and use it in GitHub Desktop.
bn.js benchmarks
Benchmarking: create-10
bn.js#create-10 x 98,920 ops/sec ±0.69% (99 runs sampled)
bignum#create-10 x 282,502 ops/sec ±3.52% (86 runs sampled)
browserify-bignum#create-10 x 153,830 ops/sec ±1.03% (94 runs sampled)
------------------------
Fastest is bignum#create-10
========================
Benchmarking: create-hex
bn.js#create-hex x 604,436 ops/sec ±0.73% (97 runs sampled)
bignum#create-hex x 270,627 ops/sec ±3.67% (84 runs sampled)
browserify-bignum#create-hex x 7,709 ops/sec ±1.86% (100 runs sampled)
------------------------
Fastest is bn.js#create-hex
========================
Benchmarking: add
bn.js#add x 4,197,618 ops/sec ±0.90% (96 runs sampled)
bignum#add x 503,322 ops/sec ±9.05% (75 runs sampled)
browserify-bignum#add x 706,843 ops/sec ±0.56% (97 runs sampled)
------------------------
Fastest is bn.js#add
========================
Benchmarking: mul
bn.js#mul x 954,112 ops/sec ±0.99% (96 runs sampled)
bignum#mul x 112,164 ops/sec ±44.19% (28 runs sampled)
browserify-bignum#mul x 25,479 ops/sec ±1.84% (100 runs sampled)
------------------------
Fastest is bn.js#mul
========================
Benchmarking: sqr
bn.js#sqr x 1,014,118 ops/sec ±0.71% (100 runs sampled)
bignum#sqr x 135,119 ops/sec ±38.41% (34 runs sampled)
browserify-bignum#sqr x 26,101 ops/sec ±0.68% (96 runs sampled)
------------------------
Fastest is bn.js#sqr
========================
Benchmarking: div
bn.js#div x 20,853 ops/sec ±0.72% (98 runs sampled)
bignum#div x 98,117 ops/sec ±28.40% (38 runs sampled)
browserify-bignum#div x 8,133 ops/sec ±1.27% (100 runs sampled)
------------------------
Fastest is bignum#div
========================
@Yaffle
Copy link

Yaffle commented May 1, 2014

Can you please compare with Tom Wu BigInteger http://www-cs-students.stanford.edu/~tjw/jsbn/ ?
Or share the source code of the benchmark?

@Yaffle
Copy link

Yaffle commented May 1, 2014

@Yaffle
Copy link

Yaffle commented May 1, 2014

Benchmarking: create-10 index.js:1224
bn.js#create-10 x 64,579 ops/sec ±0.85% (93 runs sampled) index.js:1231
Tom Wu#create-10 x 553,675 ops/sec ±0.54% (93 runs sampled) index.js:1231
------------------------ index.js:1234
Fastest is Tom Wu#create-10 index.js:1235
======================== index.js:1238
Benchmarking: create-hex index.js:1224
bn.js#create-hex x 462,186 ops/sec ±0.71% (94 runs sampled) index.js:1231
Tom Wu#create-hex x 550,544 ops/sec ±0.62% (96 runs sampled) index.js:1231
------------------------ index.js:1234
Fastest is Tom Wu#create-hex index.js:1235
======================== index.js:1238
Benchmarking: add index.js:1224
bn.js#add x 3,780,399 ops/sec ±1.02% (92 runs sampled) index.js:1231
Tom Wu#add x 2,068,560 ops/sec ±0.71% (93 runs sampled) index.js:1231
------------------------ index.js:1234
Fastest is bn.js#add index.js:1235
======================== index.js:1238
Benchmarking: mul index.js:1224
bn.js#mul x 868,261 ops/sec ±0.48% (93 runs sampled) index.js:1231
Tom Wu#mul x 1,207,418 ops/sec ±0.50% (96 runs sampled) index.js:1231
------------------------ index.js:1234
Fastest is Tom Wu#mul index.js:1235
======================== index.js:1238
Benchmarking: sqr index.js:1224
bn.js#sqr x 870,860 ops/sec ±0.62% (96 runs sampled) index.js:1231
Tom Wu#sqr x 1,157,628 ops/sec ±0.99% (93 runs sampled) index.js:1231
------------------------ index.js:1234
Fastest is Tom Wu#sqr index.js:1235
======================== index.js:1238
Benchmarking: div index.js:1224
bn.js#div x 18,021 ops/sec ±0.75% (95 runs sampled) index.js:1231
Tom Wu#div x 138,159 ops/sec ±0.76% (92 runs sampled) index.js:1231
------------------------ index.js:1234
Fastest is Tom Wu#div index.js:1235
======================== index.js:1238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment