release: WRNexusJS 0.7.0

This commit is contained in:
2026-08-01 10:04:42 +05:30
parent c54144f2e4
commit 87507edf59
207 changed files with 12607 additions and 679 deletions
+30
View File
@@ -0,0 +1,30 @@
import { describe, expect, test } from "bun:test";
import { compareBenchmark, percentile, runBenchmark } from "../src/index.ts";
describe("@wrnexus/benchmark", () => {
test("calculates percentiles and deterministic samples", async () => {
let now = 0;
const result = await runBenchmark(
"clock",
() => {
now += 2;
},
{
iterations: 3,
warmup: 0,
clock: () => now,
},
);
expect(result.samples).toEqual([2, 2, 2]);
expect(result.p95Ms).toBe(2);
expect(percentile([1, 2, 3, 4], 0.5)).toBe(2);
});
test("reports regression budget violations", () => {
const baseline = { meanMs: 10, p95Ms: 20 } as any;
const current = { meanMs: 12, p95Ms: 30, maxMs: 40, operationsPerSecond: 50 } as any;
expect(compareBenchmark(current, baseline, { meanPercent: 10, p95Percent: 20 })).toHaveLength(
2,
);
});
});