# MoonDisk performance benchmark

The benchmark measures the real native scanner against generated directory trees containing 10,000, 50,000, and 100,000 small files. It records wall-clock scan time, peak scanner-process working set, and files per second.

## Reproduce on Windows

```powershell
./scripts/benchmark.ps1
```

For a shorter check:

```powershell
./scripts/benchmark.ps1 -Counts 1000,5000
```

The script builds MoonDisk in Release mode, creates 100 directory buckets under ignored `benchmark-output`, runs the compiled executable directly, writes snapshots and results, and removes generated input files when finished. Results are saved as CSV and Markdown.

## Interpretation

- The dataset uses many small files, so results emphasize directory traversal and metadata overhead.
- Antivirus, filesystem caching, storage type, CPU, and background activity can materially change results.
- Compare regressions on the same machine and similar system state.
- Scanner limits remain active; the default maximum of one million entries is above the supplied workloads.

## Acceptance target

All three workloads must complete without scan errors or crashes. This is a reliability benchmark, not a fixed speed competition. The checked-in validation record states which workloads were run; machine-specific raw results remain ignored to avoid presenting one host as a universal performance claim.

## Validation baseline

The following run completed on Windows on 2026-09-21 using MoonBit `0.1.20260904`, a Release build, 100 directory buckets, and the generated small-file payload. Host-specific results are evidence that the workloads complete; they are not universal performance guarantees.

| Files | Directories | Seconds | Peak working set (MiB) | Files/second |
| ---: | ---: | ---: | ---: | ---: |
| 10,000 | 100 | 0.864 | 21.52 | 11,580 |
| 50,000 | 100 | 4.007 | 64.21 | 12,477 |
| 100,000 | 100 | 9.184 | 120.25 | 10,889 |

All snapshots completed without scan errors or crashes. Raw output is regenerated by the script instead of committed because it contains absolute local paths and machine-specific timing.
