mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Add routes to Bun.serve() (#17357)
This commit is contained in:
71
bench/snippets/decode.js
Normal file
71
bench/snippets/decode.js
Normal file
@@ -0,0 +1,71 @@
|
||||
import { bench, run } from "../runner.mjs";
|
||||
|
||||
let decodeURIComponentSIMD;
|
||||
if (typeof Bun !== "undefined") {
|
||||
({ decodeURIComponentSIMD } = await import("bun:internal-for-testing"));
|
||||
}
|
||||
|
||||
const hugeText = Buffer.alloc(1000000, "Hello, world!").toString();
|
||||
const hugeTextWithPercentAtEnd = Buffer.alloc(1000000, "Hello, world!%40").toString();
|
||||
|
||||
const tinyText = Buffer.alloc(100, "Hello, world!").toString();
|
||||
const tinyTextWithPercentAtEnd = Buffer.alloc(100, "Hello, world!%40").toString();
|
||||
|
||||
const veryTinyText = Buffer.alloc(8, "a").toString();
|
||||
const veryTinyTextWithPercentAtEnd = Buffer.alloc(8, "a%40").toString();
|
||||
|
||||
decodeURIComponentSIMD &&
|
||||
bench("decodeURIComponentSIMD - no % x 8 bytes", () => {
|
||||
decodeURIComponentSIMD(veryTinyText);
|
||||
});
|
||||
|
||||
bench(" decodeURIComponent - no % x 8 bytes", () => {
|
||||
decodeURIComponent(veryTinyText);
|
||||
});
|
||||
|
||||
decodeURIComponentSIMD &&
|
||||
bench("decodeURIComponentSIMD - yes % x 8 bytes", () => {
|
||||
decodeURIComponentSIMD(veryTinyTextWithPercentAtEnd);
|
||||
});
|
||||
|
||||
bench(" decodeURIComponent - yes % x 8 bytes", () => {
|
||||
decodeURIComponent(veryTinyTextWithPercentAtEnd);
|
||||
});
|
||||
|
||||
decodeURIComponentSIMD &&
|
||||
bench("decodeURIComponentSIMD - no % x 100 bytes", () => {
|
||||
decodeURIComponentSIMD(tinyText);
|
||||
});
|
||||
|
||||
bench(" decodeURIComponent - no % x 100 bytes", () => {
|
||||
decodeURIComponent(tinyText);
|
||||
});
|
||||
|
||||
decodeURIComponentSIMD &&
|
||||
bench("decodeURIComponentSIMD - yes % x 100 bytes", () => {
|
||||
decodeURIComponentSIMD(tinyTextWithPercentAtEnd);
|
||||
});
|
||||
|
||||
bench(" decodeURIComponent - yes % x 100 bytes", () => {
|
||||
decodeURIComponent(tinyTextWithPercentAtEnd);
|
||||
});
|
||||
|
||||
decodeURIComponentSIMD &&
|
||||
bench("decodeURIComponentSIMD - no % x 1 MB", () => {
|
||||
decodeURIComponentSIMD(hugeText);
|
||||
});
|
||||
|
||||
bench(" decodeURIComponent - no % x 1 MB", () => {
|
||||
decodeURIComponent(hugeText);
|
||||
});
|
||||
|
||||
decodeURIComponentSIMD &&
|
||||
bench("decodeURIComponentSIMD - yes % x 1 MB", () => {
|
||||
decodeURIComponentSIMD(hugeTextWithPercentAtEnd);
|
||||
});
|
||||
|
||||
bench(" decodeURIComponent - yes % x 1 MB", () => {
|
||||
decodeURIComponent(hugeTextWithPercentAtEnd);
|
||||
});
|
||||
|
||||
await run();
|
||||
Reference in New Issue
Block a user