# Hook Latency Benchmark

**Date**: 2026-02-28 04:13 UTC
**Policies**: 100
**Iterations**: 50 per scenario
**Platform**: Darwin arm64

## Results

| Scenario | p50 (ms) | p95 (ms) | p99 (ms) | Mean (ms) |
|----------|----------|----------|----------|-----------|
| PreToolUse: Bash allow (no match) | 37.1 | 41.0 | 44.3 | 37.6 |
| PreToolUse: Bash deny (banned import) | 42.6 | 45.5 | 46.8 | 42.9 |
| PreToolUse: Write deny (protected path) | 45.1 | 49.6 | 51.1 | 45.5 |
| PreToolUse: Read skip (no checks) | 29.6 | 31.0 | 32.3 | 29.7 |
| SessionStart (API unreachable) | 31.2 | 33.9 | 39.7 | 31.5 |

## Go Binary Results

| Scenario | p50 (ms) | p95 (ms) | p99 (ms) | Mean (ms) |
|----------|----------|----------|----------|-----------|
| Go PreToolUse: Bash allow (no match) | 22.6 | 24.5 | 178.7 | 25.8 |
| Go PreToolUse: Bash deny (banned import) | 22.7 | 24.6 | 33.0 | 23.1 |
| Go PreToolUse: Write deny (protected path) | 22.5 | 24.5 | 24.9 | 22.7 |
| Go PreToolUse: Read skip (no checks) | 22.6 | 24.5 | 29.2 | 22.8 |
| Go SessionStart (API unreachable) | 24.5 | 26.6 | 27.7 | 24.6 |

## Targets

- **PreToolUse**: <50ms p95 (shell), <10ms p95 (Go)
- **SessionStart**: <3s (with live API)

## Notes

- SessionStart benchmark uses offline mode (API unreachable, curl timeout 5s skipped).
- Shell PreToolUse benchmarks include jq parsing of 100 policies.
- Go binary uses native JSON parsing with in-memory policy cache.
- All hooks fail-open on error (exit 1 = non-blocking).
