based64
A base64 codec using wasm32 SIMD intrinsics.
use ;
use ;
or
import init, {
encode,
decode,
} from "./pkg/based64.js";
async function run(): boolean {
await init();
let data = "howdy";
let bytes = new TextEncoder().encode(data);
let ascii: Uint8Array = encode(bytes);
let rawString = decode(ascii);
return data === rawString;
}
Requirements
# make sure to have the wasm32 target installed
RUSTFLAGS=\"-C target-feature=+simd128
Benchmarks
To run benchmarks, run just bench. It should lead you to a web page, you can view the console.
The benchmark rules are very simple, it must follow window.btoa and window.atob's function header: String -> String.
Since certain functions have different function signatures, the work needed to convert into a String is included in the measurement.
Codecs measured:
base64withwasm_bindgenbindingswindow.atob(),window.btoa()based64Uint8Array->Uint8Arraywithwasm_bindgenbindingsbased64String->Stringwithwasm_bindgenbindings
Resources
- Mcyoung's Designing a SIMD Algorithm from Scratch
- Daniel Lemire's Ridiculously fast base64 encoding and decoding
- core::arch::wasm32::v128