simd-base64
v0.1.0
Published
SIMD-accelerated Base64(Url) encoding/decoding for Browser and Node.js
Downloads
135
Readme
simd-base64
SIMD-accelerated Base64(Url) encoding/decoding for Browser and Node.js

Overview
simd-base64 is an extremely fast base64 (url) encoder/decoder that works in both browser and Node.js environments. The encoding process is implemented in WebAssembly and utilizes SIMD for high-speed processing.
simd-base64 prioritizes execution speed in browser environments. In Node.js environments, the natively implemented Buffer is sufficiently fast, so we recommend using that.
Installation
$ npm i simd-base64Usage
import { decodeBase64, encodeBase64, encodeBase64Url } from "simd-base64";
const bytes = new TextEncoder().encode("hello");
encodeBase64(bytes); // "aGVsbG8="
encodeBase64Url(bytes); // "aGVsbG8"
decodeBase64("aGVsbG8");Benchmarks
Browser(Chromium)
1. base64 65536 bytes encoding
| name | hz | min | max | mean | p75 | p99 | p995 | p999 | rme | samples | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | simd-base64 | 40,912.00 | 0.0000 | 0.2000 | 0.0244 | 0.0000 | 0.1000 | 0.1000 | 0.2000 | ±2.45% | 20,456 | | js-base64 | 5,452.00 | 0.0000 | 0.4000 | 0.1834 | 0.2000 | 0.3000 | 0.3000 | 0.4000 | ±1.20% | 2,726 | | base64-js | 1,714.00 | 0.4000 | 0.8000 | 0.5834 | 0.6000 | 0.7000 | 0.8000 | 0.8000 | ±0.75% | 857 |
2. base64url 65536 bytes encoding
| name | hz | min | max | mean | p75 | p99 | p995 | p999 | rme | samples | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | simd-base64 | 41,170.00 | 0.0000 | 0.2000 | 0.0243 | 0.0000 | 0.1000 | 0.1000 | 0.2000 | ±2.44% | 20,585 | | js-base64 | 3,003.40 | 0.2000 | 0.6000 | 0.3330 | 0.4000 | 0.5000 | 0.5000 | 0.5000 | ±0.91% | 1,502 |
3. base64 65536 bytes decoding
| name | hz | min | max | mean | p75 | p99 | p995 | p999 | rme | samples | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | simd-base64 | 14,273.15 | 0.0000 | 0.2000 | 0.0701 | 0.1000 | 0.2000 | 0.2000 | 0.2000 | ±1.89% | 7,138 | | js-base64 | 334.86 | 2.8000 | 3.6000 | 2.9863 | 3.0000 | 3.5000 | 3.6000 | 3.6000 | ±0.66% | 168 | | base64-js | 6,760.00 | 0.0000 | 0.4000 | 0.1479 | 0.2000 | 0.3000 | 0.3000 | 0.3000 | ±1.35% | 3,380 |
Node.js
1. base64 65536 bytes encoding
| name | hz | min | max | mean | p75 | p99 | p995 | p999 | rme | samples | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | simd-base64 | 64,511.03 | 0.0148 | 0.0757 | 0.0155 | 0.0153 | 0.0212 | 0.0324 | 0.0418 | ±0.15% | 32,256 | | js-base64 | 124,955.74 | 0.0068 | 0.0724 | 0.0080 | 0.0080 | 0.0115 | 0.0153 | 0.0413 | ±0.21% | 62,478 | | base64-js | 1,714.67 | 0.5517 | 0.7661 | 0.5832 | 0.5865 | 0.7225 | 0.7340 | 0.7661 | ±0.43% | 858 | | Node Buffer [reference] | 123,946.00 | 0.0068 | 0.0965 | 0.0081 | 0.0081 | 0.0118 | 0.0202 | 0.0405 | ±0.22% | 61,974 |
2. base64url 65536 bytes encoding
| name | hz | min | max | mean | p75 | p99 | p995 | p999 | rme | samples | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | simd-base64 | 65,103.94 | 0.0149 | 0.0831 | 0.0154 | 0.0152 | 0.0207 | 0.0278 | 0.0386 | ±0.13% | 32,552 | | js-base64 | 5,048.08 | 0.1713 | 1.4987 | 0.1981 | 0.1953 | 0.3661 | 0.3895 | 0.6130 | ±0.88% | 2,525 | | Node Buffer [reference] | 124,096.43 | 0.0068 | 0.0842 | 0.0081 | 0.0080 | 0.0129 | 0.0230 | 0.0408 | ±0.23% | 62,049 |
3. base64 65536 bytes decoding
| name | hz | min | max | mean | p75 | p99 | p995 | p999 | rme | samples | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | simd-base64 | 31,111.44 | 0.0304 | 0.0712 | 0.0321 | 0.0318 | 0.0429 | 0.0448 | 0.0541 | ±0.12% | 15,556 | | js-base64 | 2,772.69 | 0.3363 | 2.3302 | 0.3607 | 0.3656 | 0.4075 | 0.4575 | 0.8363 | ±0.85% | 1,387 | | base64-js | 7,759.42 | 0.1217 | 0.7001 | 0.1289 | 0.1345 | 0.1567 | 0.1620 | 0.3527 | ±0.38% | 3,880 | | Node Buffer [reference] | 108,995.87 | 0.0077 | 0.9950 | 0.0092 | 0.0085 | 0.0163 | 0.0247 | 0.2364 | ±1.29% | 54,498 |
