Documentation
¶
Overview ¶
Package bench holds the benchmark harness for the M8 milestone: a deterministic fixture generator that builds a realistic .agent-memory/ tree, plus end-to-end benchmarks for the hot paths (fetch_context, propose_update, RebuildAll).
Run with:
go test -bench=. -benchmem ./internal/bench/...
See docs/bench-harness.md for interpretation guidance and current baseline numbers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildBenchProject ¶
func BuildBenchProject(tb testing.TB, size FixtureSize) string
BuildBenchProject writes a complete .agent-memory/ tree under tb.TempDir() and returns the project root. The tree is byte- deterministic for a given size — same input produces same on-disk state, so bench results are stable across runs.
Layout:
<root>/
.agent-memory/
meta/{manifest.yaml,schema.yaml,lock}
.gitignore
index.md
conventions.md
decisions.md (size.DecisionSections sections)
pitfalls.md (size.PitfallSections sections)
modules/N.md (size.Modules files, one section each)
archive/2026-NN-...md (size.ArchiveFiles files, one section each)
local/ (empty)
sessions/ (empty)
staging/ (empty)
Tests get parseability + count guarantees; benchmarks get a stable corpus that exercises every category. tb is testing.TB so the same helper works for both *testing.T and *testing.B.
Types ¶
type FixtureSize ¶
type FixtureSize struct {
// Modules is the number of files under modules/.
Modules int
// DecisionSections is the number of `## Heading` sections inside
// the single decisions.md file.
DecisionSections int
// PitfallSections is the number of sections inside pitfalls.md.
PitfallSections int
// ArchiveFiles is the number of files under archive/.
ArchiveFiles int
// SectionBodyChars is the target length (in characters) of each
// generated section body. Real-world files vary widely; this is
// "medium prose" by default.
SectionBodyChars int
}
FixtureSize controls how big a corpus BuildBenchProject generates. Counts are upper bounds; the generator may emit fewer items if a requested size is unrealistic for a category (e.g., negative).
func DefaultFixtureSize ¶
func DefaultFixtureSize() FixtureSize
DefaultFixtureSize returns a "realistic medium project" set of counts. Total ~120 sections across ~70 files, ~50 KB of Markdown.
func LargeFixtureSize ¶
func LargeFixtureSize() FixtureSize
LargeFixtureSize stresses the index + parser. Total ~600 sections across ~250 files — heavier than most real projects.
func SmallFixtureSize ¶
func SmallFixtureSize() FixtureSize
SmallFixtureSize is for quick "does it crash" benchmarks during development. Roughly an order of magnitude smaller than default.