Files
meshcore-analyzer/cmd
n30nexandn30nex cfb38e76a7 test(planner): benchmark full-range viewshed work counts (#2426)
Fixes #2424. The server’s default race-and-coverage suite ran full 30 km
and 60 km terrain diagnostics on every run. Three workflows reached
their 20-minute package deadline while the work-count test was running.

The ordinary test now exercises a 5 km grid with 2,012 classified cells
and checks the actual lookup reduction. Excluding the initial site
lookup, the single terrain walk must use at most half the reference
lookups. The missing-site test still allocates and checks the 60 km
grid. Full-size diagnostic counts are available from `cmd/server`:

```sh
go test -run '^$' -bench '^BenchmarkViewshedWorkCount$' -benchtime=1x
```

TDD exemption: pure test-harness refactor. Only
`planner_viewshed_test.go` changes. The benchmark preserves the original
grid dimensions, classified cells and lookup counts at both distances.
The existing reference-equivalence, parallel-worker, cancellation and
race checks remain in the regular suite.

Validation on Windows, Go 1.27.2, `GOMAXPROCS=2`:

- Default work-count test, native: 17.60 s before, 0.04 s after. With
race detection and atomic coverage, the original exceeded the 210 s
diagnostic limit. The candidate took 0.63 s.
- Independent benchmark reproduced 31,756,821 reference / 15,878,411
single-pass lookups at 30 km, and 62,381,281 / 31,190,641 at 60 km.
- Deliberate duplicate traversal and oversized-grid controls both failed
their intended assertions. These timings measure the test workload.
- The [hosted Go
job](https://github.com/Kpa-clawbot/CoreScope/actions/runs/44199958643/job/134451261110)
passed the full server race-and-coverage suite in 1,125.875 s under its
existing 1,200 s deadline. All browser shards passed.

Co-authored-by: n30nex <6686206+n30nex@users.noreply.github.com>
2026-11-18 18:15:58 +01:00
..