# Testing & benchmarking

> Verify archives without writing to disk, and measure performance reproducibly.

## arca test

Reads every entry and checks its CRC (or its HMAC, when the entry is encrypted) without writing anything to disk.

```sh
arca test arca.zip
arca test secret.zip -p "a password"
```

```text
174 entries verified, no errors (0.006 s)
```

Corrupt entries are reported on standard error, and the command exits with status 1 and a count of the entries that failed.

### Verifying artifacts in CI

```yaml
# with arca on the PATH; see Installation
- name: Package
  run: arca create dist.zip build/ -l best
- name: Verify
  run: arca test dist.zip
```

## arca bench

Measures the design’s performance requirements R1 and R2 against a real archive and reports PASS or FAIL.

```sh
arca bench big.zip
```

It prints the R2 figure for the archive you give it, and the `hyperfine` command for R1:

```text
Performance requirements (design document, section 05)

  R2  list without extracting
      6000 entries in a 828.8 KB archive
      1.1 ms   target < 200 ms   PASS

  R1  cold start: open and list a one-entry archive, with hyperfine
      hyperfine -N --warmup 20 'arca list tiny.zip'
```

The published figures for R1, R2 and R3, and the script that reproduces them, are on the [benchmarks](benchmarks.md) page.

## Reproducible benchmarks

- Report the best of several runs, and delete the output directory before every pass.
- Small corpora sit in the operating system’s write cache and make every tool look faster. Use data that doesn’t fit.
- When a run writes gigabytes, alternate the arms (A B B A) and measure the disk with a plain sequential write before and after.
- Compare CPU time with wall time. If they match, the program is its own bottleneck; if wall time is longer, the disk is.

> [!WARNING]
> **Alternate the arms**
>
> An ordered sweep over thread counts once showed one thread running twice as fast as sixteen. The drive was degrading as the run went on, so “more threads” really meant “later in the run”. Re-run alternating, 16 threads beat 1 thread in all three rounds.
