Skip to content

Instantly share code, notes, and snippets.

@wanderer
Created February 23, 2015 21:22
Show Gist options
  • Save wanderer/109c3dbdb430db889295 to your computer and use it in GitHub Desktop.
Save wanderer/109c3dbdb430db889295 to your computer and use it in GitHub Desktop.
JS bignum benchmarks
Benchmarking: create-10
bn.js#create-10 x 1,135,003 ops/sec ±2.69% (9 runs sampled)
bignum#create-10 x 343,963 ops/sec ±2.56% (7 runs sampled)
bigi#create-10 x 823,703 ops/sec ±1.69% (9 runs sampled)
yaffle#create-10 x 1,355,594 ops/sec ±3.45% (9 runs sampled)
silentmatt-biginteger#create-10 x 92,834 ops/sec ±5.38% (9 runs sampled)
crunch#create-10 x 14,685 ops/sec ±8.53% (7 runs sampled)
------------------------
Fastest is yaffle#create-10
========================
Benchmarking: create-hex
bn.js#create-hex x 1,619,584 ops/sec ±2.46% (9 runs sampled)
bignum#create-hex x 283,541 ops/sec ±6.69% (9 runs sampled)
bigi#create-hex x 812,707 ops/sec ±2.24% (9 runs sampled)
sjcl#create-hex x 947,148 ops/sec ±5.32% (9 runs sampled)
yaffle#create-hex x 1,129,774 ops/sec ±2.84% (9 runs sampled)
silentmatt-biginteger#create-hex x 20,382 ops/sec ±2.74% (7 runs sampled)
------------------------
Fastest is bn.js#create-hex
========================
Benchmarking: toString-10
bn.js#toString-10 x 610,007 ops/sec ±2.84% (9 runs sampled)
bignum#toString-10 x 682,255 ops/sec ±1.22% (9 runs sampled)
bigi#toString-10 x 100,820 ops/sec ±3.02% (9 runs sampled)
yaffle#toString-10 x 1,422,903 ops/sec ±2.61% (8 runs sampled)
silentmatt-biginteger#toString-10 x 4,164,332 ops/sec ±5.83% (9 runs sampled)
crunch#toString-10 x 2,742 ops/sec ±4.40% (7 runs sampled)
------------------------
Fastest is silentmatt-biginteger#toString-10
========================
Benchmarking: toString-hex
bn.js#toString-hex x 594,141 ops/sec ±2.73% (9 runs sampled)
bignum#toString-hex x 3,269,701 ops/sec ±2.81% (9 runs sampled)
bigi#toString-hex x 727,974 ops/sec ±5.20% (7 runs sampled)
sjcl#toString-hex x 585,400 ops/sec ±3.50% (9 runs sampled)
yaffle#toString-hex x 503,664 ops/sec ±3.46% (9 runs sampled)
silentmatt-biginteger#toString-hex x 14,177 ops/sec ±10.74% (8 runs sampled)
------------------------
Fastest is bignum#toString-hex
========================
Benchmarking: add
bn.js#add x 5,245,444 ops/sec ±9.61% (8 runs sampled)
bignum#add x 556,575 ops/sec ±4.79% (8 runs sampled)
bigi#add x 3,032,625 ops/sec ±2.86% (8 runs sampled)
sjcl#add x 3,626,789 ops/sec ±1.40% (9 runs sampled)
yaffle#add x 7,531,329 ops/sec ±1.96% (9 runs sampled)
silentmatt-biginteger#add x 1,602,826 ops/sec ±2.31% (9 runs sampled)
crunch#add x 175,082 ops/sec ±2.37% (9 runs sampled)
------------------------
Fastest is yaffle#add
========================
Benchmarking: sub
bn.js#sub x 7,245,108 ops/sec ±1.98% (9 runs sampled)
bignum#sub x 552,844 ops/sec ±2.08% (9 runs sampled)
bigi#sub x 2,689,666 ops/sec ±1.33% (9 runs sampled)
sjcl#sub x 3,451,874 ops/sec ±6.02% (9 runs sampled)
yaffle#sub x 7,153,766 ops/sec ±2.25% (9 runs sampled)
silentmatt-biginteger#sub x 8,129,604 ops/sec ±4.76% (9 runs sampled)
crunch#sub x 149,830 ops/sec ±7.13% (9 runs sampled)
------------------------
Fastest is silentmatt-biginteger#sub
========================
Benchmarking: mul
bn.js#mul x 1,773,500 ops/sec ±2.21% (8 runs sampled)
bignum#mul x 430,362 ops/sec ±3.80% (9 runs sampled)
bigi#mul x 700,509 ops/sec ±3.13% (9 runs sampled)
sjcl#mul x 2,516,888 ops/sec ±1.94% (9 runs sampled)
yaffle#mul x 866,753 ops/sec ±1.72% (8 runs sampled)
silentmatt-biginteger#mul x 631,173 ops/sec ±1.29% (9 runs sampled)
crunch#mul x 151,528 ops/sec ±2.91% (8 runs sampled)
------------------------
Fastest is sjcl#mul
========================
Benchmarking: sqr
bn.js#sqr x 1,776,619 ops/sec ±0.63% (9 runs sampled)
bignum#sqr x 468,955 ops/sec ±0.61% (9 runs sampled)
bigi#sqr x 435,707 ops/sec ±1.11% (9 runs sampled)
sjcl#sqr x 2,275,132 ops/sec ±0.30% (8 runs sampled)
yaffle#sqr x 887,505 ops/sec ±1.99% (9 runs sampled)
silentmatt-biginteger#sqr x 533,986 ops/sec ±1.19% (9 runs sampled)
crunch#sqr x 184,985 ops/sec ±1.93% (9 runs sampled)
------------------------
Fastest is sjcl#sqr
========================
Benchmarking: div
bn.js#div x 395,222 ops/sec ±1.88% (8 runs sampled)
bignum#div x 330,449 ops/sec ±0.38% (9 runs sampled)
bigi#div x 213,266 ops/sec ±1.53% (9 runs sampled)
yaffle#div x 471,640 ops/sec ±1.28% (9 runs sampled)
silentmatt-biginteger#div x 25,216 ops/sec ±1.82% (7 runs sampled)
crunch#div:
------------------------
Fastest is yaffle#div
========================
Benchmarking: mod
bn.js#mod x 381,539 ops/sec ±1.47% (8 runs sampled)
bignum#mod x 374,150 ops/sec ±2.98% (9 runs sampled)
bigi#mod x 202,103 ops/sec ±1.07% (9 runs sampled)
yaffle#mod x 408,589 ops/sec ±0.37% (9 runs sampled)
silentmatt-biginteger#mod x 22,012 ops/sec ±0.26% (9 runs sampled)
crunch#mod x 52,144 ops/sec ±1.43% (8 runs sampled)
------------------------
Fastest is yaffle#mod
========================
Benchmarking: mul-mod k256
bn.js#mul-mod k256 x 1,096,736 ops/sec ±0.66% (9 runs sampled)
sjcl#mul-mod k256 x 508,105 ops/sec ±1.11% (9 runs sampled)
------------------------
Fastest is bn.js#mul-mod k256
========================
Benchmarking: pow k256
bn.js#pow k256 x 1,612 ops/sec ±0.08% (9 runs sampled)
bignum#pow k256 x 43,569 ops/sec ±1.16% (7 runs sampled)
crunch#pow k256 x 932 ops/sec ±1.97% (8 runs sampled)
------------------------
Fastest is bignum#pow k256
========================
Benchmarking: invm k256
bn.js#invm k256 x 6,550 ops/sec ±0.09% (9 runs sampled)
sjcl#invm k256 x 5,202 ops/sec ±0.10% (7 runs sampled)
crunch#invm k256 x 1,384 ops/sec ±1.93% (9 runs sampled)
------------------------
Fastest is bn.js#invm k256
========================
Benchmarking: gcd
bn.js#gcd x 28,818 ops/sec ±1.89% (7 runs sampled)
bigi#gcd x 34,785 ops/sec ±0.49% (6 runs sampled)
------------------------
Fastest is bigi#gcd
========================
Benchmarking: egcd
bn.js#egcd x 7,081 ops/sec ±1.39% (9 runs sampled)
------------------------
Fastest is bn.js#egcd
========================
Benchmarking: bitLength
bn.js#bitLength x 45,113,269 ops/sec ±0.90% (9 runs sampled)
------------------------
Fastest is bn.js#bitLength
========================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment