Benchmarking Node.js zlib.crc32 with @node-rs/crc32
- Install Node.js, and choose a supported version.
- Install corepack
npm i -g corepack. - Install dependencies by running
pnpm i. - Run benchmark with
pnpm benchmark.
Node.js native crc32 computation appears to be 2.3X that of implementation provided by @node-rs/crc32.
node:zlib/crc32 vs @node-rs/crc32
┌─────────┬───────────────────┬──────────────────┬──────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼───────────────────┼──────────────────┼──────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0 │ 'node:zlib/crc32' │ '3951.3 ± 0.19%' │ '3907.0 ± 10.00' │ '254920 ± 0.06%' │ '255951 ± 657' │ 25309 │
│ 1 │ '@node-rs/crc32' │ '1702.9 ± 0.65%' │ '1633.0 ± 10.00' │ '603127 ± 0.06%' │ '612370 ± 3727' │ 58725 │
└─────────┴───────────────────┴──────────────────┴──────────────────┴────────────────────────┴────────────────────────┴─────────┘node:zlib/crc32 vs @node-rs/crc32
┌─────────┬───────────────────┬──────────────────┬──────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼───────────────────┼──────────────────┼──────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0 │ 'node:zlib/crc32' │ '3967.2 ± 0.18%' │ '3927.0 ± 10.00' │ '253777 ± 0.06%' │ '254647 ± 650' │ 25207 │
│ 1 │ '@node-rs/crc32' │ '1760.7 ± 3.67%' │ '1643.0 ± 10.00' │ '595994 ± 0.07%' │ '608643 ± 3727' │ 56796 │
└─────────┴───────────────────┴──────────────────┴──────────────────┴────────────────────────┴────────────────────────┴─────────┘node:zlib/crc32 vs @node-rs/crc32
┌─────────┬───────────────────┬──────────────────┬──────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼───────────────────┼──────────────────┼──────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0 │ 'node:zlib/crc32' │ '3963.9 ± 0.20%' │ '3907.0 ± 11.00' │ '254189 ± 0.06%' │ '255951 ± 719' │ 25228 │
│ 1 │ '@node-rs/crc32' │ '1724.4 ± 0.66%' │ '1643.0 ± 10.00' │ '596815 ± 0.07%' │ '608643 ± 3727' │ 57993 │
└─────────┴───────────────────┴──────────────────┴──────────────────┴────────────────────────┴────────────────────────┴─────────┘