benchmark
Run Go benchmarks and compare results to detect performance regressions. Use before and after performance-related changes.
Best use case
benchmark is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Run Go benchmarks and compare results to detect performance regressions. Use before and after performance-related changes.
Teams using benchmark should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/benchmark/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How benchmark Compares
| Feature / Agent | benchmark | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Run Go benchmarks and compare results to detect performance regressions. Use before and after performance-related changes.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Performance Benchmarking Run Go benchmarks to measure and compare performance. Flags regressions exceeding 10%. ## Usage - `/benchmark` - Run benchmarks on all packages - `/benchmark ./internal/index/...` - Run benchmarks on specific package - `/benchmark -compare ./...` - Compare against saved baseline ## Steps 1. **Identify benchmark targets** - If `$ARGUMENTS` specifies a package, use that - Otherwise, find packages with `*_test.go` files containing `Benchmark` functions - Focus on performance-critical packages: `internal/index/`, `internal/repo/`, `internal/api/` 2. **Run benchmarks** ```bash go test -bench=. -benchmem -count=5 $ARGUMENTS 2>&1 ``` - Use `-count=5` for statistical reliability - Use `-benchmem` to track allocations 4. **Parse and analyze results** For each benchmark, extract: - `ns/op` - Nanoseconds per operation - `B/op` - Bytes allocated per operation - `allocs/op` - Allocations per operation 5. **Check for baseline comparison** - Look for `.benchmark-baseline` file in project root - If `-compare` flag used and baseline exists, compare results 6. **Report findings** Format results as a table: ``` | Benchmark | ns/op | B/op | allocs/op | Change | |-----------|-------|------|-----------|--------| ``` Flag any metric that regressed more than 10% with a warning. 7. **Offer to save baseline** If no baseline exists or results improved, offer to save current results: ```bash go test -bench=. -benchmem -count=5 ./... > .benchmark-baseline ``` ## Performance-Critical Packages Pay special attention to: - `internal/index/` - Trigram search (hot path) - `internal/repo/` - Repository access patterns - `internal/api/search/` - Search request handling - `internal/storage/` - S3 result compression ## Example Output ``` Benchmark Results for ./internal/index/... | Benchmark | ns/op | B/op | allocs/op | |---------------------|----------|-------|-----------| | BenchmarkSearch-8 | 1234567 | 4096 | 12 | | BenchmarkOpen-8 | 567890 | 8192 | 24 | No regressions detected (threshold: 10%) ```
Related Skills
test
Run Go unit tests. Use after code changes to verify correctness.
security-scan
Run gosec and govulncheck to find security vulnerabilities. Use before releases or after dependency changes.
reindex
Trigger reindexing of a specific WordPress extension. Use to rebuild the search index for a plugin, theme, or core version.
race-check
Run Go race detector to find data races in concurrent code. Use after any change to mutexes, goroutines, or channels.
profile
Run CPU and memory profiling with pprof to identify performance hotspots. Use when investigating high resource usage.
migrate
Create and manage database migrations using goose. Use for schema changes, new tables, or index optimization.
lint
Run golangci-lint and static analysis on Go code. Use before pushing or to check code quality.
integration-test
Run integration tests that require Docker (Postgres, MinIO via testcontainers). Use to validate database and storage behavior.
generate
Run go generate to build templ templates and frontend assets. Use after changing templates or CSS/JS.
deps
Check and tidy Go module dependencies. Use after adding/removing imports or before releases.
coverage
Run tests with coverage analysis and identify untested code paths. Use to find gaps before releases.
check
Run pre-push quality checks (vet + lint + tests with race detector). Use before pushing code.