Skip to content

Benchmarks

Jason Dreyzehner edited this page Jun 19, 2020 · 5 revisions

Last updated: June 19, 2020 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/83.0.4103.0).

Browser

browser: sha1: hash a 32-byte input

libauth x 421,279 ops/sec ±0.52% (67 runs sampled)
hash.js x 384,781 ops/sec ±1.78% (65 runs sampled)
crypto.subtle x 36,517 ops/sec ±2.10% (50 runs sampled)
asmcrypto.js x 3,328 ops/sec ±1.61% (21 runs sampled)

Fastest is libauth

browser: sha1: hash a 100-byte input

libauth x 517,526 ops/sec ±1.40% (63 runs sampled)
hash.js x 245,215 ops/sec ±1.49% (63 runs sampled)
crypto.subtle x 37,071 ops/sec ±2.36% (55 runs sampled)
asmcrypto.js x 3,283 ops/sec ±1.72% (21 runs sampled)

Fastest is libauth

browser: sha1: hash a 1000-byte input

libauth x 111,292 ops/sec ±1.82% (63 runs sampled)
crypto.subtle x 35,383 ops/sec ±1.87% (59 runs sampled)
hash.js x 19,429 ops/sec ±2.39% (50 runs sampled)
asmcrypto.js x 3,307 ops/sec ±2.32% (60 runs sampled)

Fastest is libauth

browser: sha1: hash a 10000-byte input

crypto.subtle x 24,083 ops/sec ±2.33% (58 runs sampled)
libauth x 12,475 ops/sec ±1.68% (63 runs sampled)
asmcrypto.js x 2,930 ops/sec ±1.94% (60 runs sampled)
hash.js x 1,578 ops/sec ±5.99% (33 runs sampled)

Fastest is crypto.subtle

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

asmcrypto.js x 9.59 ops/sec ±2.15% (28 runs sampled)
libauth x 3.43 ops/sec ±2.26% (13 runs sampled)
hash.js x 0.73 ops/sec ±1.28% (6 runs sampled)

Fastest is asmcrypto.js

browser: sha256: hash a 32-byte input

libauth x 571,012 ops/sec ±2.38% (62 runs sampled)
hash.js x 346,025 ops/sec ±1.31% (63 runs sampled)
crypto.subtle x 37,260 ops/sec ±2.15% (58 runs sampled)
asmcrypto.js x 3,138 ops/sec ±2.38% (20 runs sampled)

Fastest is libauth

browser: sha256: hash a 100-byte input

libauth x 388,597 ops/sec ±2.08% (61 runs sampled)
hash.js x 209,644 ops/sec ±0.90% (64 runs sampled)
crypto.subtle x 35,797 ops/sec ±2.50% (58 runs sampled)
asmcrypto.js x 2,903 ops/sec ±3.12% (54 runs sampled)

Fastest is libauth

browser: sha256: hash a 1000-byte input

libauth x 79,164 ops/sec ±1.86% (61 runs sampled)
crypto.subtle x 31,400 ops/sec ±2.52% (56 runs sampled)
hash.js x 27,693 ops/sec ±2.33% (62 runs sampled)
asmcrypto.js x 2,937 ops/sec ±2.79% (19 runs sampled)

Fastest is libauth

browser: sha256: hash a 10000-byte input

crypto.subtle x 16,829 ops/sec ±2.18% (58 runs sampled)
libauth x 8,879 ops/sec ±1.48% (49 runs sampled)
hash.js x 3,117 ops/sec ±1.37% (65 runs sampled)
asmcrypto.js x 2,273 ops/sec ±2.53% (57 runs sampled)

Fastest is crypto.subtle

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

asmcrypto.js x 3.74 ops/sec ±7.12% (14 runs sampled)
libauth x 2.61 ops/sec ±3.61% (11 runs sampled)
hash.js x 0.71 ops/sec ±1.67% (6 runs sampled)

Fastest is asmcrypto.js

browser: sha512: hash a 32-byte input

libauth x 362,580 ops/sec ±3.05% (60 runs sampled)
hash.js x 105,271 ops/sec ±2.85% (60 runs sampled)
crypto.subtle x 35,539 ops/sec ±2.17% (55 runs sampled)
asmcrypto.js x 2,634 ops/sec ±3.53% (52 runs sampled)

Fastest is libauth

browser: sha512: hash a 100-byte input

libauth x 361,084 ops/sec ±3.12% (60 runs sampled)
hash.js x 104,662 ops/sec ±3.13% (57 runs sampled)
crypto.subtle x 35,218 ops/sec ±2.95% (57 runs sampled)
asmcrypto.js x 2,839 ops/sec ±2.25% (19 runs sampled)

Fastest is libauth

browser: sha512: hash a 1000-byte input

libauth x 99,287 ops/sec ±2.36% (63 runs sampled)
crypto.subtle x 31,617 ops/sec ±2.26% (57 runs sampled)
hash.js x 7,628 ops/sec ±2.36% (62 runs sampled)
asmcrypto.js x 2,408 ops/sec ±3.07% (58 runs sampled)

Fastest is libauth

browser: sha512: hash a 10000-byte input

crypto.subtle x 15,668 ops/sec ±3.74% (49 runs sampled)
libauth x 11,866 ops/sec ±2.06% (63 runs sampled)
asmcrypto.js x 1,326 ops/sec ±2.18% (61 runs sampled)
hash.js x 720 ops/sec ±1.82% (60 runs sampled)

Fastest is crypto.subtle

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

libauth x 4.06 ops/sec ±0.93% (15 runs sampled)
asmcrypto.js x 1.07 ops/sec ±1.46% (7 runs sampled)
hash.js x 0.26 ops/sec ±2.02% (5 runs sampled)

Fastest is libauth

browser: ripemd160: hash a 32-byte input

libauth x 994,913 ops/sec ±0.35% (67 runs sampled)
hash.js x 419,494 ops/sec ±1.51% (65 runs sampled)

Fastest is libauth

browser: ripemd160: hash a 100-byte input

libauth x 789,779 ops/sec ±1.58% (57 runs sampled)
hash.js x 245,804 ops/sec ±1.41% (67 runs sampled)

Fastest is libauth

browser: ripemd160: hash a 1000-byte input

libauth x 250,345 ops/sec ±1.10% (68 runs sampled)
hash.js x 34,408 ops/sec ±0.73% (68 runs sampled)

Fastest is libauth

browser: ripemd160: hash a 10000-byte input

libauth x 32,111 ops/sec ±0.24% (68 runs sampled)
hash.js x 3,667 ops/sec ±1.17% (23 runs sampled)

Fastest is libauth

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

libauth x 9.69 ops/sec ±2.47% (28 runs sampled)
hash.js x 0.77 ops/sec ±2.38% (6 runs sampled)

Fastest is libauth

Browser benchmark complete, closing browser. ✔ crypto › hash.browser.bench › # browser: HeadlessChrome/83.0.4103.0 (7m 46.3s)

Node

node: ripemd160: hash a 32-byte input

libauth x 871,522 ops/sec ±2.79% (86 runs sampled)
bcoin x 652,830 ops/sec ±1.93% (83 runs sampled)
hash.js x 417,565 ops/sec ±1.39% (90 runs sampled)
node.js native x 356,808 ops/sec ±8.42% (72 runs sampled)

Fastest is libauth

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

node: ripemd160: hash a 100-byte input

libauth x 751,169 ops/sec ±1.50% (95 runs sampled)
bcoin x 563,365 ops/sec ±1.83% (81 runs sampled)
node.js native x 340,910 ops/sec ±8.03% (76 runs sampled)
hash.js x 236,951 ops/sec ±1.36% (97 runs sampled)

Fastest is libauth

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

node: ripemd160: hash a 1000-byte input

libauth x 241,645 ops/sec ±1.63% (97 runs sampled)
bcoin x 189,412 ops/sec ±1.45% (85 runs sampled)
node.js native x 158,245 ops/sec ±5.86% (85 runs sampled)
hash.js x 31,550 ops/sec ±1.38% (94 runs sampled)

Fastest is libauth

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

node: ripemd160: hash a 10000-byte input

libauth x 28,924 ops/sec ±2.53% (92 runs sampled)
node.js native x 24,758 ops/sec ±0.89% (94 runs sampled)
bcoin x 23,496 ops/sec ±0.75% (90 runs sampled)
hash.js x 3,235 ops/sec ±2.81% (90 runs sampled)

Fastest is libauth

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

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

libauth x 8.96 ops/sec ±2.22% (26 runs sampled)
node.js native x 8.24 ops/sec ±0.95% (25 runs sampled)
hash.js x 0.55 ops/sec ±6.70% (6 runs sampled)

Fastest is libauth

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

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

secp256k1-node x 17,679 ops/sec ±1.35% (94 runs sampled)
libauth x 3,744 ops/sec ±2.08% (89 runs sampled)
elliptic x 475 ops/sec ±2.24% (87 runs sampled)

Fastest is secp256k1-node

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

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

secp256k1-node x 16,568 ops/sec ±1.52% (93 runs sampled)
libauth x 3,787 ops/sec ±1.89% (94 runs sampled)
elliptic x 448 ops/sec ±2.79% (87 runs sampled)

Fastest is secp256k1-node

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

bench: secp256k1: derive compressed pubkey

secp256k1-node x 32,017 ops/sec ±1.84% (91 runs sampled)
libauth x 11,633 ops/sec ±1.20% (95 runs sampled)
elliptic x 1,516 ops/sec ±1.60% (95 runs sampled)

Fastest is secp256k1-node

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

bench: secp256k1: create DER Low-S signature

secp256k1-node x 18,149 ops/sec ±2.53% (89 runs sampled)
libauth x 5,673 ops/sec ±0.86% (96 runs sampled)
elliptic x 1,048 ops/sec ±1.59% (91 runs sampled)

Fastest is secp256k1-node

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

bench: secp256k1: sign: Schnorr vs. ECDSA

secp256k1.signMessageHashDER x 5,695 ops/sec ±1.67% (95 runs sampled)
secp256k1.signMessageHashSchnorr x 4,879 ops/sec ±2.39% (93 runs sampled)

Fastest is secp256k1.signMessageHashDER

✔ crypto › secp256k1.bench › bench: secp256k1: sign: Schnorr vs. ECDSA (11.7s)

bench: secp256k1: verify: Schnorr vs. ECDSA

secp256k1.verifySignatureSchnorr (Schnorr, pubkey compressed) x 5,037 ops/sec ±1.49% (95 runs sampled)
secp256k1.verifySignatureDERLowS (ECDSA, pubkey compressed) x 3,823 ops/sec ±2.42% (92 runs sampled)

Fastest is secp256k1.verifySignatureSchnorr (Schnorr, pubkey compressed)

✔ crypto › secp256k1.bench › bench: secp256k1: verify: Schnorr vs. ECDSA (11.8s)

node: sha1: hash a 32-byte input

bcoin x 717,516 ops/sec ±2.10% (83 runs sampled)
libauth x 516,215 ops/sec ±4.02% (84 runs sampled)
hash.js x 422,595 ops/sec ±1.51% (88 runs sampled)
node.js native x 336,459 ops/sec ±8.27% (65 runs sampled)
asmcrypto.js x 9,312 ops/sec ±2.89% (78 runs sampled)

Fastest is bcoin

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

node: sha1: hash a 100-byte input

bcoin x 634,722 ops/sec ±2.47% (84 runs sampled)
libauth x 376,443 ops/sec ±0.94% (90 runs sampled)
node.js native x 369,094 ops/sec ±8.12% (72 runs sampled)
hash.js x 256,507 ops/sec ±1.08% (90 runs sampled)
asmcrypto.js x 9,720 ops/sec ±1.52% (83 runs sampled)

Fastest is bcoin

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

node: sha1: hash a 1000-byte input

bcoin x 287,430 ops/sec ±2.75% (85 runs sampled)
node.js native x 262,998 ops/sec ±7.61% (72 runs sampled)
libauth x 79,585 ops/sec ±0.70% (97 runs sampled)
hash.js x 35,294 ops/sec ±1.87% (94 runs sampled)
asmcrypto.js x 8,899 ops/sec ±1.90% (84 runs sampled)

Fastest is bcoin, node.js native

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

node: sha1: hash a 10000-byte input

node.js native x 76,624 ops/sec ±3.66% (89 runs sampled)
bcoin x 45,145 ops/sec ±2.34% (91 runs sampled)
libauth x 8,178 ops/sec ±2.42% (93 runs sampled)
asmcrypto.js x 7,095 ops/sec ±2.01% (85 runs sampled)
hash.js x 3,883 ops/sec ±1.58% (95 runs sampled)

Fastest is node.js native

✔ crypto › 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 29.69 ops/sec ±1.20% (53 runs sampled)
asmcrypto.js x 10.05 ops/sec ±0.75% (29 runs sampled)
libauth x 2.71 ops/sec ±3.31% (11 runs sampled)
hash.js x 0.64 ops/sec ±3.67% (6 runs sampled)

Fastest is node.js native

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

node: sha256: hash a 32-byte input

bcoin x 632,099 ops/sec ±2.31% (86 runs sampled)
libauth x 462,743 ops/sec ±1.95% (95 runs sampled)
hash.js x 379,012 ops/sec ±0.86% (91 runs sampled)
node.js native x 367,052 ops/sec ±9.36% (70 runs sampled)
asmcrypto.js x 8,921 ops/sec ±1.95% (84 runs sampled)

Fastest is bcoin

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

node: sha256: hash a 100-byte input

bcoin x 510,474 ops/sec ±2.68% (82 runs sampled)
libauth x 340,966 ops/sec ±0.23% (98 runs sampled)
node.js native x 340,367 ops/sec ±9.37% (69 runs sampled)
hash.js x 216,501 ops/sec ±0.75% (96 runs sampled)
asmcrypto.js x 9,544 ops/sec ±1.35% (89 runs sampled)

Fastest is bcoin

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

node: sha256: hash a 1000-byte input

node.js native x 215,437 ops/sec ±7.23% (81 runs sampled)
bcoin x 190,664 ops/sec ±0.52% (90 runs sampled)
libauth x 59,101 ops/sec ±1.06% (96 runs sampled)
hash.js x 30,744 ops/sec ±0.05% (100 runs sampled)
asmcrypto.js x 9,255 ops/sec ±1.29% (83 runs sampled)

Fastest is node.js native

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

node: sha256: hash a 10000-byte input

node.js native x 39,381 ops/sec ±2.20% (92 runs sampled)
bcoin x 24,156 ops/sec ±0.77% (92 runs sampled)
libauth x 6,422 ops/sec ±0.64% (98 runs sampled)
asmcrypto.js x 5,454 ops/sec ±1.83% (87 runs sampled)
hash.js x 3,244 ops/sec ±0.73% (97 runs sampled)

Fastest is node.js native

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

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

node.js native x 12.95 ops/sec ±4.08% (36 runs sampled)
asmcrypto.js x 4.11 ops/sec ±1.40% (15 runs sampled)
libauth x 1.95 ops/sec ±4.04% (9 runs sampled)
hash.js x 0.58 ops/sec ±1.25% (6 runs sampled)

Fastest is node.js native

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

node: sha512: hash a 32-byte input

bcoin x 622,344 ops/sec ±2.10% (84 runs sampled)
libauth x 354,164 ops/sec ±2.92% (90 runs sampled)
node.js native x 335,956 ops/sec ±10.64% (68 runs sampled)
hash.js x 140,731 ops/sec ±0.22% (96 runs sampled)
asmcrypto.js x 7,175 ops/sec ±3.32% (81 runs sampled)

Fastest is bcoin

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

node: sha512: hash a 100-byte input

bcoin x 592,292 ops/sec ±2.78% (84 runs sampled)
libauth x 364,661 ops/sec ±1.89% (96 runs sampled)
node.js native x 315,349 ops/sec ±11.00% (64 runs sampled)
hash.js x 131,996 ops/sec ±1.25% (93 runs sampled)
asmcrypto.js x 6,773 ops/sec ±2.37% (78 runs sampled)

Fastest is bcoin

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

node: sha512: hash a 1000-byte input

bcoin x 252,300 ops/sec ±3.31% (79 runs sampled)
node.js native x 186,654 ops/sec ±11.33% (66 runs sampled)
libauth x 86,497 ops/sec ±2.64% (91 runs sampled)
hash.js x 8,926 ops/sec ±1.92% (92 runs sampled)
asmcrypto.js x 3,911 ops/sec ±7.85% (57 runs sampled)

Fastest is bcoin

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

node: sha512: hash a 10000-byte input

node.js native x 37,760 ops/sec ±5.00% (76 runs sampled)
bcoin x 25,011 ops/sec ±3.46% (74 runs sampled)
libauth x 6,462 ops/sec ±1.79% (80 runs sampled)
asmcrypto.js x 1,339 ops/sec ±3.15% (80 runs sampled)
hash.js x 653 ops/sec ±1.76% (83 runs sampled)

Fastest is node.js native

✔ crypto › 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 18.87 ops/sec ±3.38% (36 runs sampled)
libauth x 2.60 ops/sec ±7.16% (11 runs sampled)
asmcrypto.js x 0.78 ops/sec ±3.72% (6 runs sampled)
hash.js x 0.21 ops/sec ±5.52% (5 runs sampled)

Fastest is node.js native

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

node: binToBigIntUintBE vs. binToHex -> BigInt()

binToBigIntUintBE x 203,920 ops/sec ±4.83% (77 runs sampled)
binToHex -> BigInt() x 150,192 ops/sec ±3.77% (75 runs sampled)

Fastest is binToBigIntUintBE

✔ format › numbers.bench › node: binToBigIntUintBE vs. binToHex -> BigInt() (11.9s)

node: numberToBinUint16LE vs. numberToBinUint16LEClamped

numberToBinUint16LE x 1,488,670 ops/sec ±3.00% (74 runs sampled)
numberToBinUint16LEClamped x 1,390,207 ops/sec ±3.84% (80 runs sampled)

Fastest is numberToBinUint16LE, numberToBinUint16LEClamped

✔ format › numbers.bench › node: numberToBinUint16LE vs. numberToBinUint16LEClamped (11.6s)

node: numberToBinUint32LE vs. numberToBinUint32LEClamped

numberToBinUint32LE x 1,535,926 ops/sec ±3.36% (78 runs sampled)
numberToBinUint32LEClamped x 991,941 ops/sec ±2.96% (81 runs sampled)

Fastest is numberToBinUint32LE

✔ format › numbers.bench › node: numberToBinUint32LE vs. numberToBinUint32LEClamped (11.8s)

node: bigIntToBinUint64LE vs. bigIntToBinUint64LEClamped

bigIntToBinUint64LE x 1,493,238 ops/sec ±3.13% (78 runs sampled)
bigIntToBinUint64LEClamped x 434,246 ops/sec ±3.09% (86 runs sampled)

Fastest is bigIntToBinUint64LE

✔ format › numbers.bench › node: bigIntToBinUint64LE vs. bigIntToBinUint64LEClamped (11.7s)

Clone this wiki locally