Files
bun.sh/bench/snippets/arraybuffersink.mjs
Jarred Sumner 10996a797a 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>
2022-11-26 21:04:38 -08:00

31 lines
691 B
JavaScript

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();