diff options
author | 2022-09-22 23:44:53 -0700 | |
---|---|---|
committer | 2022-09-22 23:45:02 -0700 | |
commit | 2c1926993bc4d94f9e7bc4d171217a707efd385c (patch) | |
tree | 827148c57920e40ad48c4c6d73ceec68a9b21c96 /bench/snippets/blob.mjs | |
parent | e14a3af491ece8d1b0309e76ae3022b4fad91f16 (diff) | |
download | bun-2c1926993bc4d94f9e7bc4d171217a707efd385c.tar.gz bun-2c1926993bc4d94f9e7bc4d171217a707efd385c.tar.zst bun-2c1926993bc4d94f9e7bc4d171217a707efd385c.zip |
Faster `Blob` + begin to implement `FileSink`
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(); |