diff --git a/package.json b/package.json index 8cd68c3..769a920 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "workspaces": ["src", "example"], "scripts": { + "bench": "vitest bench", "build": "bun run clean && tsc --project ./tsconfig.build.json && bun .scripts/postbuild.ts", "changeset": "changeset", "changeset:release": "bun run build && changeset publish", diff --git a/src/response.bench.tsx b/src/response.bench.tsx new file mode 100644 index 0000000..b7e1fd9 --- /dev/null +++ b/src/response.bench.tsx @@ -0,0 +1,27 @@ +import { bench, expect } from "vitest"; +import { ImageResponse } from "./response.js"; + +bench("png", async () => { + const response = new ImageResponse( +
+ hello +
, + ); + expect(response).toBeDefined(); + expect(new Uint8Array(await response.arrayBuffer())).toBeDefined(); +}); + +bench("svg", async () => { + const response = new ImageResponse( +
+ hello +
, + { format: "svg" }, + ); + expect(response).toBeDefined(); + expect(new Uint8Array(await response.arrayBuffer())).toBeDefined(); +}); diff --git a/src/utils/svgToPng.test.tsx b/src/utils/svgToPng.test.tsx index ed7967a..0a613c6 100644 --- a/src/utils/svgToPng.test.tsx +++ b/src/utils/svgToPng.test.tsx @@ -3,7 +3,7 @@ import { elementToSvg } from "./elementToSvg.js"; import { initializeWasm } from "./initializeWasm.js"; import { svgToPng } from "./svgToPng.js"; -test("default", async () => { +test.skip("default", async () => { await initializeWasm(); const svg = await elementToSvg(