Skip to content

Benchmarks

Jason Dreyzehner edited this page Jul 31, 2018 · 5 revisions

Last updated: July 30, 2018 Source

For the latest benchmarks, choose a benchmark job in Circle CI and view the results of the yarn run bench task.

Results in Node.js should generally extend to the browser, but because the browser also supports the Crypto.subtle API, we run the hashing benchmarks in a browser as well (below, HeadlessChrome/69.0.3452.0).

Node

node: sha512: hash a 32-byte input

bcoin x 690,353 ops/sec ±2.19% (80 runs sampled)
bitcoin-ts x 204,650 ops/sec ±0.98% (85 runs sampled)
node.js native x 203,804 ops/sec ±5.63% (80 runs sampled)
hash.js x 103,824 ops/sec ±0.49% (89 runs sampled)
asmcrypto.js x 2,288 ops/sec ±3.10% (64 runs sampled)

Fastest is bcoin

✔ sha512.bench › node: sha512: hash a 32-byte input (30.1s)

node: sha512: hash a 100-byte input

bcoin x 386,749 ops/sec ±4.45% (81 runs sampled)
node.js native x 193,705 ops/sec ±5.63% (79 runs sampled)
bitcoin-ts x 177,795 ops/sec ±1.78% (80 runs sampled)
hash.js x 101,425 ops/sec ±0.90% (89 runs sampled)
asmcrypto.js x 2,277 ops/sec ±2.81% (65 runs sampled)

Fastest is bcoin

✔ sha512.bench › node: sha512: hash a 100-byte input (29.6s)

node: sha512: hash a 1000-byte input

bcoin x 237,257 ops/sec ±2.70% (87 runs sampled)
node.js native x 144,398 ops/sec ±4.39% (80 runs sampled)
bitcoin-ts x 71,048 ops/sec ±0.57% (93 runs sampled)
hash.js x 10,775 ops/sec ±0.59% (88 runs sampled)
asmcrypto.js x 2,000 ops/sec ±3.43% (68 runs sampled)

Fastest is bcoin

✔ sha512.bench › node: sha512: hash a 1000-byte input (30.3s)

node: sha512: hash a 10000-byte input

bcoin x 39,531 ops/sec ±1.18% (91 runs sampled)
node.js native x 35,092 ops/sec ±1.80% (87 runs sampled)
bitcoin-ts x 9,076 ops/sec ±1.98% (90 runs sampled)
asmcrypto.js x 1,051 ops/sec ±1.67% (79 runs sampled)
hash.js x 875 ops/sec ±0.39% (90 runs sampled)

Fastest is bcoin

✔ sha512.bench › node: sha512: hash a 10000-byte input (29.5s)

node: sha512: incrementally hash a 32MB input in 1MB chunks

node.js native x 13.34 ops/sec ±0.78% (36 runs sampled)
bitcoin-ts x 3.00 ops/sec ±0.67% (12 runs sampled)
asmcrypto.js x 0.63 ops/sec ±0.78% (6 runs sampled)
hash.js x 0.20 ops/sec ±3.63% (5 runs sampled)

Fastest is node.js native

✔ sha512.bench › node: sha512: incrementally hash a 32MB input in 1MB chunks (1m 28.8s)

node: sha256: hash a 32-byte input

bcoin x 624,000 ops/sec ±2.56% (83 runs sampled)
hash.js x 351,590 ops/sec ±0.87% (92 runs sampled)
bitcoin-ts x 232,430 ops/sec ±1.40% (86 runs sampled)
node.js native x 224,557 ops/sec ±4.77% (81 runs sampled)
asmcrypto.js x 2,537 ops/sec ±2.84% (60 runs sampled)

Fastest is bcoin

✔ sha256.bench › node: sha256: hash a 32-byte input (30.5s)

node: sha256: hash a 100-byte input

bcoin x 420,771 ops/sec ±5.44% (74 runs sampled)
node.js native x 208,342 ops/sec ±4.46% (81 runs sampled)
hash.js x 191,333 ops/sec ±1.68% (87 runs sampled)
bitcoin-ts x 169,389 ops/sec ±2.14% (84 runs sampled)
asmcrypto.js x 2,586 ops/sec ±3.60% (60 runs sampled)

Fastest is bcoin

✔ sha256.bench › node: sha256: hash a 100-byte input (29.9s)

node: sha256: hash a 1000-byte input

bcoin x 183,676 ops/sec ±2.41% (81 runs sampled)
node.js native x 131,335 ops/sec ±3.34% (83 runs sampled)
bitcoin-ts x 45,486 ops/sec ±0.75% (86 runs sampled)
hash.js x 32,043 ops/sec ±0.58% (90 runs sampled)
asmcrypto.js x 2,603 ops/sec ±2.25% (66 runs sampled)

Fastest is bcoin

✔ sha256.bench › node: sha256: hash a 1000-byte input (29.9s)

node: sha256: hash a 10000-byte input

bcoin x 27,889 ops/sec ±1.26% (87 runs sampled)
node.js native x 26,013 ops/sec ±1.75% (89 runs sampled)
bitcoin-ts x 5,247 ops/sec ±3.23% (91 runs sampled)
hash.js x 3,465 ops/sec ±1.11% (90 runs sampled)
asmcrypto.js x 2,248 ops/sec ±2.08% (76 runs sampled)

Fastest is bcoin

✔ sha256.bench › node: sha256: hash a 10000-byte input (30.2s)

node: sha256: incrementally hash a 32MB input in 1MB chunks

node.js native x 9.41 ops/sec ±0.50% (27 runs sampled)
asmcrypto.js x 3.56 ops/sec ±1.44% (13 runs sampled)
bitcoin-ts x 1.72 ops/sec ±0.98% (9 runs sampled)
hash.js x 0.53 ops/sec ±0.49% (6 runs sampled)

Fastest is node.js native

✔ sha256.bench › node: sha256: incrementally hash a 32MB input in 1MB chunks (53s)

node: sha1: hash a 32-byte input

bcoin x 802,680 ops/sec ±2.21% (84 runs sampled)
hash.js x 407,761 ops/sec ±0.93% (90 runs sampled)
bitcoin-ts x 288,827 ops/sec ±0.98% (87 runs sampled)
node.js native x 239,569 ops/sec ±4.95% (77 runs sampled)
asmcrypto.js x 2,728 ops/sec ±3.83% (59 runs sampled)

Fastest is bcoin

✔ sha1.bench › node: sha1: hash a 32-byte input (30.1s)

node: sha1: hash a 100-byte input

bcoin x 493,222 ops/sec ±6.79% (81 runs sampled)
bitcoin-ts x 228,953 ops/sec ±1.14% (87 runs sampled)
node.js native x 226,722 ops/sec ±4.79% (79 runs sampled)
hash.js x 187,242 ops/sec ±0.52% (87 runs sampled)
asmcrypto.js x 2,855 ops/sec ±2.82% (64 runs sampled)

Fastest is bcoin

✔ sha1.bench › node: sha1: hash a 100-byte input (29.9s)

node: sha1: hash a 1000-byte input

bcoin x 306,461 ops/sec ±4.62% (76 runs sampled)
node.js native x 171,659 ops/sec ±4.22% (81 runs sampled)
bitcoin-ts x 62,303 ops/sec ±0.76% (90 runs sampled)
hash.js x 22,516 ops/sec ±0.63% (89 runs sampled)
asmcrypto.js x 2,744 ops/sec ±3.30% (62 runs sampled)

Fastest is bcoin

✔ sha1.bench › node: sha1: hash a 1000-byte input (30s)

node: sha1: hash a 10000-byte input

bcoin x 59,026 ops/sec ±1.09% (78 runs sampled)
node.js native x 52,789 ops/sec ±1.12% (92 runs sampled)
bitcoin-ts x 7,527 ops/sec ±0.56% (92 runs sampled)
asmcrypto.js x 2,597 ops/sec ±2.65% (67 runs sampled)
hash.js x 2,156 ops/sec ±0.55% (90 runs sampled)

Fastest is bcoin

✔ sha1.bench › node: sha1: hash a 10000-byte input (29.9s)

node: sha1: incrementally hash a 32MB input in 1MB chunks

node.js native x 21.06 ops/sec ±0.22% (38 runs sampled)
asmcrypto.js x 8.88 ops/sec ±0.36% (26 runs sampled)
bitcoin-ts x 2.40 ops/sec ±0.29% (10 runs sampled)
hash.js x 0.40 ops/sec ±0.58% (6 runs sampled)

Fastest is node.js native

✔ sha1.bench › node: sha1: incrementally hash a 32MB input in 1MB chunks (55.9s)

bench: secp256k1: verify signature Low-S, uncompressed pubkey

secp256k1-node x 10,805 ops/sec ±0.10% (92 runs sampled)
bitcoin-ts x 3,482 ops/sec ±1.65% (89 runs sampled)
elliptic x 388 ops/sec ±0.83% (88 runs sampled)

Fastest is secp256k1-node

✔ secp256k1.bench › bench: secp256k1: verify signature Low-S, uncompressed pubkey (18s)

bench: secp256k1: verify signature Low-S, compressed pubkey

secp256k1-node x 10,112 ops/sec ±0.13% (93 runs sampled)
bitcoin-ts x 3,404 ops/sec ±0.09% (93 runs sampled)
elliptic x 351 ops/sec ±2.98% (80 runs sampled)

Fastest is secp256k1-node

✔ secp256k1.bench › bench: secp256k1: verify signature Low-S, compressed pubkey (17.7s)

bench: secp256k1: derive compressed pubkey

secp256k1-node x 25,894 ops/sec ±0.08% (89 runs sampled)
bitcoin-ts x 10,018 ops/sec ±0.45% (87 runs sampled)
elliptic x 1,142 ops/sec ±1.33% (91 runs sampled)

Fastest is secp256k1-node

✔ secp256k1.bench › bench: secp256k1: derive compressed pubkey (17.9s)

bench: secp256k1: create DER Low-S signature

secp256k1-node x 14,488 ops/sec ±2.02% (88 runs sampled)
bitcoin-ts x 4,601 ops/sec ±0.16% (90 runs sampled)
elliptic x 866 ops/sec ±0.57% (89 runs sampled)

Fastest is secp256k1-node

✔ secp256k1.bench › bench: secp256k1: create DER Low-S signature (17.8s)

node: ripemd160: hash a 32-byte input

bcoin x 758,384 ops/sec ±2.13% (82 runs sampled)
bitcoin-ts x 356,921 ops/sec ±1.20% (81 runs sampled)
hash.js x 346,768 ops/sec ±0.81% (89 runs sampled)
node.js native x 236,040 ops/sec ±4.68% (78 runs sampled)

Fastest is bcoin

✔ ripemd160.bench › node: ripemd160: hash a 32-byte input (23.9s)

node: ripemd160: hash a 100-byte input

bcoin x 635,729 ops/sec ±1.85% (83 runs sampled)
bitcoin-ts x 356,740 ops/sec ±1.41% (90 runs sampled)
node.js native x 223,940 ops/sec ±4.63% (84 runs sampled)
hash.js x 191,879 ops/sec ±0.58% (90 runs sampled)

Fastest is bcoin

✔ ripemd160.bench › node: ripemd160: hash a 100-byte input (24.1s)

node: ripemd160: hash a 1000-byte input

bcoin x 178,775 ops/sec ±0.88% (88 runs sampled)
bitcoin-ts x 165,407 ops/sec ±1.25% (93 runs sampled)
node.js native x 117,563 ops/sec ±3.29% (81 runs sampled)
hash.js x 29,042 ops/sec ±0.42% (86 runs sampled)

Fastest is bcoin

✔ ripemd160.bench › node: ripemd160: hash a 1000-byte input (23.8s)

node: ripemd160: hash a 10000-byte input

bitcoin-ts x 26,046 ops/sec ±0.91% (94 runs sampled)
bcoin x 22,039 ops/sec ±0.17% (91 runs sampled)
node.js native x 20,719 ops/sec ±0.74% (91 runs sampled)
hash.js x 3,239 ops/sec ±0.26% (92 runs sampled)

Fastest is bitcoin-ts

✔ ripemd160.bench › node: ripemd160: hash a 10000-byte input (23.8s)

node: ripemd160: incrementally hash a 32MB input in 1MB chunks

bitcoin-ts x 8.49 ops/sec ±0.10% (25 runs sampled)
node.js native x 7.08 ops/sec ±0.58% (22 runs sampled)
hash.js x 0.51 ops/sec ±0.41% (6 runs sampled)

Fastest is bitcoin-ts

✔ ripemd160.bench › node: ripemd160: incrementally hash a 32MB input in 1MB chunks (39.8s)

Browser

browser: sha1: hash a 32-byte input

hash.js x 269,115 ops/sec ±1.99% (58 runs sampled)
bitcoin-ts x 237,005 ops/sec ±2.55% (61 runs sampled)
crypto.subtle x 14,271 ops/sec ±4.43% (51 runs sampled)
asmcrypto.js x 4,149 ops/sec ±4.35% (50 runs sampled)

Fastest is hash.js

browser: sha1: hash a 100-byte input

bitcoin-ts x 251,624 ops/sec ±1.13% (62 runs sampled)
hash.js x 154,116 ops/sec ±1.14% (64 runs sampled)
crypto.subtle x 12,399 ops/sec ±6.11% (47 runs sampled)
asmcrypto.js x 4,105 ops/sec ±2.99% (25 runs sampled)

Fastest is bitcoin-ts

browser: sha1: hash a 1000-byte input

bitcoin-ts x 55,467 ops/sec ±0.70% (63 runs sampled)
hash.js x 19,134 ops/sec ±1.04% (64 runs sampled)
crypto.subtle x 12,652 ops/sec ±5.09% (48 runs sampled)
asmcrypto.js x 4,017 ops/sec ±1.35% (24 runs sampled)

Fastest is bitcoin-ts

browser: sha1: hash a 10000-byte input

crypto.subtle x 9,218 ops/sec ±2.25% (48 runs sampled)
bitcoin-ts x 6,317 ops/sec ±0.44% (36 runs sampled)
asmcrypto.js x 3,554 ops/sec ±2.22% (22 runs sampled)
hash.js x 1,855 ops/sec ±1.08% (61 runs sampled)

Fastest is crypto.subtle

browser: sha1: incrementally hash a 32MB input in 1MB chunks

asmcrypto.js x 8.46 ops/sec ±2.11% (25 runs sampled)
bitcoin-ts x 1.83 ops/sec ±0.96% (9 runs sampled)
hash.js x 0.44 ops/sec ±1.52% (6 runs sampled)

Fastest is asmcrypto.js

browser: sha256: hash a 32-byte input

hash.js x 270,121 ops/sec ±0.92% (64 runs sampled)
bitcoin-ts x 253,430 ops/sec ±0.25% (64 runs sampled)
crypto.subtle x 15,178 ops/sec ±5.02% (53 runs sampled)
asmcrypto.js x 4,263 ops/sec ±4.08% (54 runs sampled)

Fastest is hash.js

browser: sha256: hash a 100-byte input

bitcoin-ts x 177,468 ops/sec ±1.20% (63 runs sampled)
hash.js x 164,577 ops/sec ±0.22% (64 runs sampled)
crypto.subtle x 10,692 ops/sec ±4.31% (41 runs sampled)
asmcrypto.js x 4,192 ops/sec ±2.29% (25 runs sampled)

Fastest is bitcoin-ts

browser: sha256: hash a 1000-byte input

bitcoin-ts x 37,884 ops/sec ±1.87% (63 runs sampled)
hash.js x 26,529 ops/sec ±1.46% (60 runs sampled)
crypto.subtle x 10,109 ops/sec ±3.17% (49 runs sampled)
asmcrypto.js x 3,677 ops/sec ±5.85% (49 runs sampled)

Fastest is bitcoin-ts

browser: sha256: hash a 10000-byte input

crypto.subtle x 7,716 ops/sec ±3.37% (41 runs sampled)
bitcoin-ts x 4,299 ops/sec ±2.23% (26 runs sampled)
hash.js x 3,208 ops/sec ±0.21% (64 runs sampled)
asmcrypto.js x 3,018 ops/sec ±1.74% (20 runs sampled)

Fastest is crypto.subtle

browser: sha256: incrementally hash a 32MB input in 1MB chunks

asmcrypto.js x 3.55 ops/sec ±0.19% (13 runs sampled)
bitcoin-ts x 1.43 ops/sec ±1.35% (8 runs sampled)
hash.js x 0.61 ops/sec ±1.62% (6 runs sampled)

Fastest is asmcrypto.js

browser: sha512: hash a 32-byte input

bitcoin-ts x 209,366 ops/sec ±0.38% (64 runs sampled)
hash.js x 85,753 ops/sec ±2.72% (62 runs sampled)
crypto.subtle x 14,663 ops/sec ±5.23% (53 runs sampled)
asmcrypto.js x 3,846 ops/sec ±5.12% (53 runs sampled)

Fastest is bitcoin-ts

browser: sha512: hash a 100-byte input

bitcoin-ts x 195,834 ops/sec ±2.19% (61 runs sampled)
hash.js x 86,873 ops/sec ±0.71% (63 runs sampled)
crypto.subtle x 14,479 ops/sec ±5.03% (53 runs sampled)
asmcrypto.js x 3,493 ops/sec ±3.73% (22 runs sampled)

Fastest is bitcoin-ts

browser: sha512: hash a 1000-byte input

bitcoin-ts x 52,074 ops/sec ±4.65% (52 runs sampled)
crypto.subtle x 11,982 ops/sec ±5.59% (49 runs sampled)
hash.js x 9,489 ops/sec ±1.41% (50 runs sampled)
asmcrypto.js x 3,332 ops/sec ±5.05% (54 runs sampled)

Fastest is bitcoin-ts

browser: sha512: hash a 10000-byte input

crypto.subtle x 8,955 ops/sec ±2.35% (57 runs sampled)
bitcoin-ts x 8,639 ops/sec ±0.29% (46 runs sampled)
asmcrypto.js x 1,335 ops/sec ±1.91% (60 runs sampled)
hash.js x 804 ops/sec ±1.25% (54 runs sampled)

Fastest is crypto.subtle

browser: sha512: incrementally hash a 32MB input in 1MB chunks

bitcoin-ts x 2.76 ops/sec ±0.23% (11 runs sampled)
asmcrypto.js x 0.72 ops/sec ±0.63% (6 runs sampled)
hash.js x 0.25 ops/sec ±2.49% (5 runs sampled)

Fastest is bitcoin-ts

browser: ripemd160: hash a 32-byte input

bitcoin-ts x 545,697 ops/sec ±0.25% (63 runs sampled)
hash.js x 271,080 ops/sec ±0.39% (65 runs sampled)

Fastest is bitcoin-ts

browser: ripemd160: hash a 100-byte input

bitcoin-ts x 468,949 ops/sec ±0.86% (64 runs sampled)
hash.js x 157,284 ops/sec ±0.55% (64 runs sampled)

Fastest is bitcoin-ts

browser: ripemd160: hash a 1000-byte input

bitcoin-ts x 177,850 ops/sec ±0.86% (60 runs sampled)
hash.js x 24,770 ops/sec ±0.69% (64 runs sampled)

Fastest is bitcoin-ts

browser: ripemd160: hash a 10000-byte input

bitcoin-ts x 24,377 ops/sec ±0.72% (62 runs sampled)
hash.js x 2,597 ops/sec ±0.54% (62 runs sampled)

Fastest is bitcoin-ts

browser: ripemd160: incrementally hash a 32MB input in 1MB chunks

bitcoin-ts x 7.91 ops/sec ±0.69% (24 runs sampled)
hash.js x 0.56 ops/sec ±0.36% (6 runs sampled)

Fastest is bitcoin-ts

Browser benchmark complete, closing browser. ✔ hash.browser.bench › # browser: HeadlessChrome/69.0.3452.0 (8m 23.9s)

Clone this wiki locally