Files
bun.sh/bench/snippets/blob.mjs
Michael H b54137174b Bench updates (#15029)
Co-authored-by: RiskyMH <RiskyMH@users.noreply.github.com>
2024-11-08 23:15:24 -08:00

31 lines
665 B
JavaScript

import { bench, run } from "../runner.mjs";
bench("new Blob(['hello world'])", function () {
return new Blob(["hello world"]);
});
var small = new Blob([JSON.stringify("hello world ")]);
bench("blob.text(small string)", function () {
return small.text();
});
bench("blob.arrayBuffer(small string)", function () {
return small.arrayBuffer();
});
// if (Blob.prototype.json) {
// bench("blob.json(small string)", function () {
// return small.json();
// });
// }
bench("blob.slice()", function () {
return small.slice();
});
if ((await small.text()) !== JSON.stringify("hello world ")) {
throw new Error("blob.text() failed");
}
await run();