diff options
Diffstat (limited to 'bench/snippets/blob.mjs')
-rw-r--r-- | bench/snippets/blob.mjs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bench/snippets/blob.mjs b/bench/snippets/blob.mjs new file mode 100644 index 000000000..68ebc1ce4 --- /dev/null +++ b/bench/snippets/blob.mjs @@ -0,0 +1,30 @@ +import { bench, run } from "../node_modules/mitata/src/cli.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(); |