From bbe39dbda12ce4c71e73ffccdded18869916e86e Mon Sep 17 00:00:00 2001 From: Joe Boccanfuso Date: Tue, 11 Aug 2026 15:14:27 -0400 Subject: [PATCH] chore(runner): Test the runner and bench with a comment. --- packages/big-endian/bench/decode.bench.js | 32 ++++++++++++----------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/big-endian/bench/decode.bench.js b/packages/big-endian/bench/decode.bench.js index 152d3ae..45c14a4 100644 --- a/packages/big-endian/bench/decode.bench.js +++ b/packages/big-endian/bench/decode.bench.js @@ -1,33 +1,35 @@ -import { bench, describe } from "vitest" -import decode from "../src/index.js" +import { bench, describe } from "vitest"; +import decode from "../src/index.js"; -const SIZE_512x512 = 512 * 512 +const SIZE_512x512 = 512 * 512; + +// REMOVE THIS COMMENT. IT IS JUST BEING ADDED SO THE BENCH CAN RUN. function makeBuffer(byteLen) { - const data = new Uint8Array(byteLen) - for (let i = 0; i < byteLen; i++) data[i] = (i * 37) & 0xff - return data + const data = new Uint8Array(byteLen); + for (let i = 0; i < byteLen; i++) data[i] = (i * 37) & 0xff; + return data; } describe("big-endian decode (byte-swap)", () => { - const data16 = makeBuffer(SIZE_512x512 * 2) + const data16 = makeBuffer(SIZE_512x512 * 2); bench("16-bit unsigned + swap, 512x512", () => { - decode({ bitsAllocated: 16, pixelRepresentation: 0 }, data16) - }) + decode({ bitsAllocated: 16, pixelRepresentation: 0 }, data16); + }); bench("16-bit signed + swap, 512x512", () => { - decode({ bitsAllocated: 16, pixelRepresentation: 1 }, data16) - }) + decode({ bitsAllocated: 16, pixelRepresentation: 1 }, data16); + }); // The 16-bit benches above do real per-pixel swap work and are left // unbatched. The 8-bit path is a bare property assignment, so a single // call is swamped by fixed harness overhead and cache-model variation // across runner CPUs; batch x100 so the body is measurable. - const data8 = makeBuffer(SIZE_512x512) + const data8 = makeBuffer(SIZE_512x512); bench("8-bit passthrough, 512x512 x100", () => { for (let i = 0; i < 100; i++) { - decode({ bitsAllocated: 8 }, data8) + decode({ bitsAllocated: 8 }, data8); } - }) -}) + }); +});