# Reproducible benchmark

The benchmark is a deterministic smoke workload for comparing changes to the
simulation, matrix diagnostics, network robustness, and MPA selection pipeline.
It is intentionally small enough for local runs and CI.

## Workload

- Fixture: `12-node-reference`
- Nodes: 5 Paracel sample nodes, 6 Spratly sample nodes with unique IDs, and 1
  explicit connector node used to keep the fixture dimension fixed.
- Particles: 80 per node
- Replicates: 3
- Seed sequence: `20260824`, `20268743`, `20276662`
- Flow: `FlowField::new`, 20 × 20 grid, diffusion coefficient `1.0`, zero
  advective velocity. This is a repeatability control scenario, not a claim
  that the synthetic flow is field-calibrated.
- Simulation: 14 days, one-hour time step
- Matrix: built from the first replicate's transition counts
- MPA search: greedy, genetic (`population=12`, `generations=10`), and
  simulated annealing (`iterations=30`) candidates compared on a Pareto
  frontier.
- Robustness order: nodes `[0, 5, 10, 11]`

Run it from the repository root:

```text
moon run src/main.mbt -- benchmark
```

## Measured result

Measured locally on 2026-08-24 with MoonBit `0.1.20260819` / MoonC `0.10.9`.
The command completed in **499.23 ms** under PowerShell. The default `moon run`
path uses MoonBit's default wasm target; this wall-clock sample includes
process startup, wasm execution, and any cached build overhead. It is a local
reproducibility sample, not a cross-platform performance claim. For a native
comparison, run `moon run --target native src/main.mbt -- benchmark` and record
that result separately.

```text
reef-connect benchmark
fixture=12-node-reference
reef_count=12 particles_per_reef=80 replicates=3 base_seed=20260824
simulation
settled_rate=0.4753472222222222 ci95_lower=0.4717460607154954 ci95_upper=0.478948383728949
dead_rate=0.5246527777777777 lost_rate=0
matrix
matrix_density=0.08333333333333333 matrix_quality=1
robustness
baseline_flux=5.6625000000000005 final_retention=0.6688741721854303 robustness_area=3.3222958057395138
mpa
selected_mpas=3 protected_area_km2=145 portfolio_score=70.7375
```

The values above are generated by the executable at runtime. If source code,
toolchain, or platform changes, rerun the command and record the new output
instead of treating these values as a permanent performance guarantee.
