-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
perf(ext/web): use base64-simd for atob/btoa #14992
Conversation
@Nugine it looks like there are relevant failures in the CI. |
The decoding function is forgiving-base64-decode. I have fixed it locally. The step "Remove all ASCII whitespace from data." is even slower than base64 decoding. I'm trying to make it faster. (Nugine/simd#4) |
Bench result:
CPU: bench function// Extracted from <https://github.com/denoland/deno/blob/main/cli/bench/deno_common.js>
function bench(name, n, f) {
const t1 = performance.now();
for (let i = 0; i < n; ++i) {
f(i);
}
const t2 = performance.now();
const dt = (t2 - t1) / 1e3;
const freq = n / dt;
const time = (t2 - t1) / n;
const msg = [
`${name}: \t`,
`n = ${n}, \t`,
`dt = ${dt.toFixed(3)}s, \t`,
`freq = ${freq.toFixed(3)}/s, \t`,
]
if (time >= 1) {
msg.push(`time = ${time.toFixed(3)}ms/op`)
} else {
msg.push(`time = ${(time * 1e6).toFixed(0)}ns/op`)
}
console.log(msg.join(""))
}
function b64Long() {
const input = "helloworld".repeat(1e5);
bench("b64Long", 100, () => {
atob(btoa(input));
});
}
function b64Short() {
const input = "123";
bench("b64Short", 1e6, () => {
atob(btoa(input));
});
}
b64Long();
b64Short(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
rebased |
baseline (direct rust call)
|
resolves #14980
Related: #13841