AtlatestRepositorysigil-format
sigil-format / tree / benchREADME.md
1
# Tokenizer validation + benchmarks3
## The CLI-embedded-module trap (read first)5
The `sigil` CLI **embeds** `(sigil format ...)` for its `format` subcommand, and6
the embedded modules SHADOW this package's local build in `sigil test`,7
`sigil eval`, and direct file runs. Importing `(sigil format tokenize)` in a8
test or bench therefore exercises the CLI's bundled version, NOT your working9
tree. (Verified 2026-07-16: an export added locally is unbound at runtime;10
SIGIL_LIB / -L / store-cache flush / version bump do not change resolution.)12
Workaround used by these harnesses: create a renamed copy of the module and13
import that — the embedded CLI has no `(sigil format tokenize2)`:15
sed 's/(define-library (sigil format tokenize)/(define-library (sigil format tokenize2)/' \16
src/sigil/format/tokenize.sgl > src/sigil/format/tokenize2.sgl17
sigil build19
The `tokenize2.sgl` copy is gitignored scratch — regenerate it after every20
tokenize.sgl edit, and never commit it.22
## Harnesses24
- `bench-diff.sgl` — differential correctness: compares the local build25
(via tokenize2) against the v0.16.2 implementation inlined verbatim in the26
file. Token streams must be byte-identical (all 6 token fields, the chars27
vector, and token-value strings) across edge cases, this repo's own source28
files, and a generated corpus. Run: `sigil eval -f bench/bench-diff.sgl`29
(use `eval -f`, NOT a direct file run — the direct runner swallows all30
runtime errors silently and exits 0).31
- `bench-perf.sgl` — timing, one measurement per process:32
`BENCH_IMPL=cli|local BENCH_LINES=n sigil eval -f bench/bench-perf.sgl`.33
`cli` = the CLI's embedded tokenizer, `local` = the tokenize2 copy.34
Wall-clock on a busy box is noisy; prefer paired/min-of-N comparisons.