From 10996a797a6cae831a292b40f80ed3446277eccb Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 26 Nov 2022 21:04:38 -0800 Subject: 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> --- bench/snippets/write-file.mjs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 bench/snippets/write-file.mjs (limited to 'bench/snippets/write-file.mjs') diff --git a/bench/snippets/write-file.mjs b/bench/snippets/write-file.mjs new file mode 100644 index 000000000..b13104bfc --- /dev/null +++ b/bench/snippets/write-file.mjs @@ -0,0 +1,25 @@ +import { readFileSync, writeFileSync } from "node:fs"; +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); + +bench(`${short.length} ascii`, () => { + writeFileSync("/tmp/bun.bench-out.txt", short); +}); + +bench(`${short.length} utf8`, () => { + writeFileSync("/tmp/bun.bench-out.txt", shortUTF16); +}); + +bench(`${long.length} ascii`, () => { + writeFileSync("/tmp/bun.bench-out.txt", long); +}); + +bench(`${longUTF16.length} utf8`, () => { + writeFileSync("/tmp/bun.bench-out.txt", longUTF16); +}); + +await run(); -- cgit v1.2.3