1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

bench: add base64 roundtrip (#13839)

This commit is contained in:
Divy Srivastava 2022-03-05 02:15:24 +05:30 committed by GitHub
parent 060dabee4c
commit 18a3a0ba75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,6 +37,13 @@ function benchStats(name, n, t1, t2) {
`n = ${n}, dt = ${dt.toFixed(3)}s, r = ${r.toFixed(0)}/s, t = ${ns}ns/op`; `n = ${n}, dt = ${dt.toFixed(3)}s, r = ${r.toFixed(0)}/s, t = ${ns}ns/op`;
} }
function benchBase64RoundTrip() {
const input = "long-string".repeat(99999);
benchSync("base64_roundtrip", 10, () => {
atob(btoa(input));
});
}
function benchUrlParse() { function benchUrlParse() {
benchSync("url_parse", 5e4, (i) => { benchSync("url_parse", 5e4, (i) => {
new URL(`http://www.google.com/${i}`); new URL(`http://www.google.com/${i}`);
@ -110,6 +117,7 @@ async function main() {
// A common "language feature", that should be fast // A common "language feature", that should be fast
// also a decent representation of a non-trivial JSON-op // also a decent representation of a non-trivial JSON-op
benchUrlParse(); benchUrlParse();
benchBase64RoundTrip();
// IO ops // IO ops
benchReadZero(); benchReadZero();
benchWriteNull(); benchWriteNull();