Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ Thumbs.db

# Local agent state and worktrees
.claude/
.vitest/
25 changes: 9 additions & 16 deletions benchmarks/analyze-budget-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ interface BenchmarkObservation {
readonly state: string;
}

interface BenchmarkTaskResult {
readonly result?: {
readonly state: string;
readonly benchmark?: {
readonly mean: number;
readonly sampleCount: number;
};
};
}

interface ReporterRuntime {
readonly fail: () => void;
readonly write: (message: string) => void;
Expand Down Expand Up @@ -71,16 +61,19 @@ export class AnalyzeBudgetReporter implements Reporter {
}

onTestCaseResult(testCase: ReportedTestCase): void {
if (!Object.hasOwn(ANALYZE_BUDGETS_MS, testCase.name) || !testCase.meta().benchmark) return;
if (!Object.hasOwn(ANALYZE_BUDGETS_MS, testCase.name)) return;

const task = testCase as ReportedTestCase & { readonly task: BenchmarkTaskResult };
const result = task.task.result;
const benchmark = result?.benchmark;
const result = testCase.result();
const benchmark = testCase.benchmarks().flatMap((entry) => entry.tasks)[0];
if (this.#observations.has(testCase.name)) this.#duplicates.add(testCase.name);
this.#observations.set(
testCase.name,
benchmark
? { mean: benchmark.mean, sampleCount: benchmark.sampleCount, state: result.state }
? {
mean: benchmark.latency.mean,
sampleCount: benchmark.latency.samplesCount,
state: result.state,
}
: undefined,
);
}
Expand All @@ -96,7 +89,7 @@ export class AnalyzeBudgetReporter implements Reporter {
}

const result = this.#observations.get(name);
if (!result || result.state !== "pass") {
if (!result || result.state !== "passed") {
failures.push(`${name}: successful benchmark result missing`);
} else if (!Number.isFinite(result.mean) || result.mean <= 0) {
failures.push(`${name}: benchmark mean must be finite and positive`);
Expand Down
16 changes: 12 additions & 4 deletions benchmarks/analyze.bench.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bench, describe, expect, inject } from "vite-plus/test";
import { describe, expect, inject, test } from "vite-plus/test";
import { runAnalysis } from "../src/analyze/runner";

const { mediumWorkspace, largeWorkspace, monorepo } = inject("analyzerFixtures");
Expand All @@ -24,7 +24,15 @@ async function analyzeFixture(root: string, expectedFiles: number): Promise<void
}

describe("askr analyze", () => {
bench("50-file workspace", () => analyzeFixture(mediumWorkspace, 50), benchOptions);
bench("250-file workspace", () => analyzeFixture(largeWorkspace, 250), benchOptions);
bench("5-workspace monorepo with 250 files", () => analyzeFixture(monorepo, 250), benchOptions);
test("50-file workspace", async ({ bench }) => {
await bench("50-file workspace", () => analyzeFixture(mediumWorkspace, 50)).run(benchOptions);
});
test("250-file workspace", async ({ bench }) => {
await bench("250-file workspace", () => analyzeFixture(largeWorkspace, 250)).run(benchOptions);
});
test("5-workspace monorepo with 250 files", async ({ bench }) => {
await bench("5-workspace monorepo with 250 files", () => analyzeFixture(monorepo, 250)).run(
benchOptions,
);
});
});
Loading
Loading