proposal-arraybuffer-base64
proposal-arraybuffer-base64 copied to clipboard
add outputOffset to the `into` methods
Split out out from https://github.com/tc39/proposal-arraybuffer-base64/pull/33.
Won't be in this proposal unless implementation or user feedback demonstrates need during stage 3.
Some numbers, finally. From this: https://jsperf.app/qafule/12
Looks like about the following speedups from using an offset:
- Chrome: 28% faster
- Safari: 18% faster
- Firefox: 31% faster
Microbenchmark, but those numbers mean this decision can affect performance on the hot path.
I made another micro benchmark (one using TextEncoder.encodeInto()) that shows an even more stark improvement.
- Using a write-offset and
str.substring()is:- Chrome: 53% faster
- Firefox: 138% faster
- Safari: 71% faster
- Using a write-offset and read-offset:
- Chrome: 16% faster (?)
- Firefox: 158% faster
- Safari: 122% faster
For fun, I also threw in an attempt to use premade subarrays to use with TextEncoder.encodeInto. Doing so is also considerably faster than creating subarrays on-the-fly:
- Chrome: 37% faster
- Firefox: 49% faster
- Safari: 29% faster
I don't know if it's expensive to create subarrays, or if it's the GC pressure, but subarrays suck.