---
id: TASK-12
title: Add Criterion benchmarks
status: Done
assignee:
  - codex
created_date: '2026-02-26 13:35'
updated_date: '2026-02-26 13:39'
labels: []
dependencies: []
references:
  - benches/benches.rs
  - src/config/load.rs
  - src/core/config.rs
  - src/core/cmd.rs
  - docs/spec.md
  - docs/plan.md
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Introduce Criterion benchmarks to measure key operations (config loading, resolution, command dispatch) and document how to run them.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 `benches/benches.rs` includes at least three meaningful benchmarks for core operations (e.g., config load/parse, config resolve, command dispatch helpers).
- [x] #2 Benchmarks run via `just benchmark` or `cargo bench` and complete without external toolchain/network dependencies.
- [x] #3 Benchmarks use stable inputs (fixtures/temp dirs) and are documented in `docs/` if required by project guidelines.
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
Plan:
1) Replace the placeholder fibonacci benchmark in `benches/benches.rs` with three meaningful benches: config load/parse (`load_config`), config resolution (`resolve_single`), and cache parsing (`get_cache_var`/`is_configured`).
2) Use stable, hermetic inputs via temp directories and pre-written files; avoid external toolchain calls.
3) Skip docs unless required (no benchmark guidance found in docs/spec.md or docs/plan.md); otherwise add a short note on running `just benchmark`.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Replaced placeholder fibonacci bench with benchmarks for config load (`load_config`), config resolution (`resolve_single`), and command run (`cmd::run` profiles). Benchmarks use temp dirs and in-memory config. `just benchmark` failed in this environment due to Criterion socket permissions; `cargo bench` completed successfully.
<!-- SECTION:NOTES:END -->

## Final Summary

<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Replaced the placeholder benchmark with Criterion benches for config loading, config resolution, and command execution (`cmd::run` profiles), using hermetic temp dirs and in-memory configs. `cargo bench` runs successfully; `just benchmark` failed here due to Criterion socket permissions in the sandbox.

Tests: `cargo bench`
<!-- SECTION:FINAL_SUMMARY:END -->
