diff options
author | 2022-11-26 21:04:38 -0800 | |
---|---|---|
committer | 2022-11-26 21:04:38 -0800 | |
commit | 10996a797a6cae831a292b40f80ed3446277eccb (patch) | |
tree | 7da625d903dc2166d4b611d9e366ff96f0c9ebe9 /bench/snippets/arraybuffersink.mjs | |
parent | 949d715a141890286d3b04ded8e209ac899ed2af (diff) | |
download | bun-10996a797a6cae831a292b40f80ed3446277eccb.tar.gz bun-10996a797a6cae831a292b40f80ed3446277eccb.tar.zst bun-10996a797a6cae831a292b40f80ed3446277eccb.zip |
Faster UTF16 -> UTF8 and UTF8 -> UTF16 (#1552)
* Fix freezing test
* Add SIMDUTF
* More micro bench snippets
* Update .gitattributes
* Update .gitattributes
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'bench/snippets/arraybuffersink.mjs')
-rw-r--r-- | bench/snippets/arraybuffersink.mjs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bench/snippets/arraybuffersink.mjs b/bench/snippets/arraybuffersink.mjs new file mode 100644 index 000000000..0e787dd56 --- /dev/null +++ b/bench/snippets/arraybuffersink.mjs @@ -0,0 +1,30 @@ +import { ArrayBufferSink } from "bun"; +import { bench, run } from "mitata"; + +var short = "Hello World!"; +var shortUTF16 = "Hello World 💕💕💕"; +var long = "Hello World!".repeat(1024); +var longUTF16 = "Hello World 💕💕💕".repeat(1024); +var encoder = new ArrayBufferSink({ stream: true, highWaterMark: 512 }); + +bench(`${short.length} ascii`, () => { + encoder.write(short); + encoder.start(); +}); + +bench(`${short.length} utf8`, () => { + encoder.write(shortUTF16); + encoder.start(); +}); + +bench(`${long.length} ascii`, () => { + encoder.write(long); + encoder.start(); +}); + +bench(`${longUTF16.length} utf8`, () => { + encoder.write(longUTF16); + encoder.start(); +}); + +await run(); |