# HNSW Search Benchmark — Baseline `20260519T212453Z`

First measured baseline that ADR-125 Phase 6 commits so the README perf table has a real referent.

## Environment

| Field | Value |
| --- | --- |
| Package | `@claude-flow/memory@3.0.0-alpha.17` (head of `feat/adr-125-memory-consolidation`) |
| Node | `v22.22.1` |
| Vitest | `4.0.16` |
| OS | `darwin 25.1.0` (macOS) |
| CPU | Apple Silicon (M-series) |
| Date | 2026-05-19 (UTC) |

## Scenario

- `HNSWIndex` from `src/hnsw-index.ts` (canonical, post-ADR-125-Phase-1 surface).
- 1,000 random 128-dim cosine-normalized vectors pre-loaded.
- Bench source: `benchmarks/hnsw-search.bench.ts`.
- Raw script: `benchmarks/results/scripts/run-baseline.mjs`.

## Results

| Metric | Value | Notes |
| --- | --- | --- |
| `build_time_ms` | **533.42 ms** | Sequential `addPoint()` × 1,000. |
| `search_k10_avg_ms` | **0.5294 ms** | 200-iteration average, post-warmup. |
| `search_k50_avg_ms` | **0.5235 ms** | k=50 nearly identical to k=10 — heap-based candidate selection dominates. |
| `add_avg_ms` | **0.8656 ms** | Incremental insert after the initial 1k. |
| `search_k10_ops_per_sec` | **1,888.9 ops/s** | Derived from `search_k10_avg_ms`. |
| `search_k50_ops_per_sec` | **1,910.1 ops/s** | Derived from `search_k50_avg_ms`. |

## Raw JSON

```json
{
  "build_time_ms": 533.42,
  "search_k10_avg_ms": 0.5294,
  "search_k50_avg_ms": 0.5235,
  "add_avg_ms": 0.8656,
  "search_k10_ops_per_sec": 1888.9,
  "search_k50_ops_per_sec": 1910.1
}
```

## How to reproduce

```bash
cd v3/@claude-flow/memory
npm run build
npm run bench       # runs benchmarks/hnsw-search.bench.ts under vitest
# OR
node benchmarks/results/scripts/run-baseline.mjs
```

## Notes for future runs

- ADR-125 Phase 3 (persistent HNSW) will add `serialize` / `deserialize` benchmarks here. The post-Phase-3 baseline should show **cold-start** restoration ≤ 50% of `build_time_ms`.
- ADR-125 Phase 4 (consolidator) will add a `sweepExpired` measurement.
- These numbers are device-specific; CI baselines will replace this file once the GitHub Actions bench job lands.
