mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
* 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>
34 lines
655 B
JavaScript
34 lines
655 B
JavaScript
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 TextEncoder();
|
|
|
|
bench(`4 ascii`, () => {
|
|
encoder.encode("heyo");
|
|
});
|
|
|
|
bench(`4 utf8`, () => {
|
|
encoder.encode("💕💕");
|
|
});
|
|
|
|
bench(`${short.length} ascii`, () => {
|
|
encoder.encode(short);
|
|
});
|
|
|
|
bench(`${short.length} utf8`, () => {
|
|
encoder.encode(shortUTF16);
|
|
});
|
|
|
|
bench(`${long.length} ascii`, () => {
|
|
encoder.encode(long);
|
|
});
|
|
|
|
bench(`${longUTF16.length} utf8`, () => {
|
|
encoder.encode(longUTF16);
|
|
});
|
|
|
|
await run();
|