This project benchmarks the performance of Uint8Array.fromBase64 for decoding base64-encoded data using different datasets.
- Images: Single base64-encoded image files (
bing.txt,googlelogo.txt). - DNS: Multiple base64-encoded lines from
swedenzonebase.txt, decoded individually. - Emails: Multiple base64-encoded email files, decoded individually and concatenated.
- Node.js (version 25.5.0 or later for native
Uint8Array.fromBase64support) or Bun. - The base64 data files in the
base64data/directory.
node benchmark.jsTo reduce GC jitter, use:
node --max-old-space-size=1000 --max-semi-space-size=512 --noconcurrent_sweeping benchmark.jsbun run benchmark.jsThe script will load all data at startup, then run 100 iterations of each benchmark, reporting average, min, and max times, as well as throughput in GB/s (where 1 GB = 1000³ bytes).
Loading data...
Data loaded.
Running benchmark: Decode bing.txt
Min throughput: 1.500 GB/s
Average throughput: 1.645 GB/s
Max throughput: 2.000 GB/s
...
- If
Uint8Array.fromBase64is not available, it falls back toBuffer.fromwith base64 decoding. - Benchmarks measure decoding performance only; data loading is done upfront.