Files
bun.sh/bench/snippets/react-dom-render.bun.js
Michael H b54137174b Bench updates (#15029)
Co-authored-by: RiskyMH <RiskyMH@users.noreply.github.com>
2024-11-08 23:15:24 -08:00

40 lines
2.0 KiB
JavaScript

import { renderToReadableStream as renderToReadableStreamBun } from "react-dom/server";
import { renderToReadableStream } from "react-dom/server.browser";
import { bench, group, run } from "../runner.mjs";
const App = () => (
<div>
<h1>Hello, world!</h1>
<p>This is a React component This is a React component This is a React component This is a React component.</p>
<p>This is a React component This is a React component This is a React component This is a React component.</p>
<p>This is a React component This is a React component This is a React component This is a React component.</p>
<p>This is a React component This is a React component This is a React component This is a React component.</p>
<p>This is a React component This is a React component This is a React component This is a React component.</p>
</div>
);
group("new Response(stream).text()", () => {
bench("react-dom/server.browser", async () => await new Response(await renderToReadableStream(<App />)).text());
bench("react-dom/server.bun", async () => await new Response(await renderToReadableStreamBun(<App />)).text());
});
group("new Response(stream).arrayBuffer()", () => {
bench(
"react-dom/server.browser",
async () => await new Response(await renderToReadableStream(<App />)).arrayBuffer(),
);
bench("react-dom/server.bun", async () => await new Response(await renderToReadableStreamBun(<App />)).arrayBuffer());
});
group("new Response(stream).bytes()", () => {
bench("react-dom/server.browser", async () => await new Response(await renderToReadableStream(<App />)).bytes());
bench("react-dom/server.bun", async () => await new Response(await renderToReadableStreamBun(<App />)).bytes());
});
group("new Response(stream).blob()", () => {
bench("react-dom/server.browser", async () => await new Response(await renderToReadableStream(<App />)).blob());
bench("react-dom/server.bun", async () => await new Response(await renderToReadableStreamBun(<App />)).blob());
});
await run();