vile / bench / ports / README.md
39 lines · 32 sloc · 2.08 KB · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw

Port input benchmark

Build with v -cc gcc -prod -o /tmp/vile-ports bench/ports, then run /tmp/vile-ports --size 1000000 --samples 15.

Each case warms up once and reports an odd-sample median. Timings include port creation, buffering, framing, lexical/reader validation, and conversion to mutable runtime data. String/symbol lengths and every list integer are checked after timing. The integer stream checks count and sum during its read loop and validates both afterwards. A failed read/result exits nonzero.

The host Reader copies from prepared memory in chunks; no filesystem or process startup time is included. A numeric list and a stream of separate numeric data exercise different paths. These numbers do not measure evaluator execution.

An alternating three-round comparison on this checkout, using five measured samples per case per round (one warm-up), measured the following median of the three reported medians:

Input Initial port path ms Optimized path ms
1 MB string 8.657 2.691
3 MB escaped string 33.922 24.262
1 MB identifier 7.349 0.827
1 million integers in one list 239.544 171.445
1 million separate integers 452.371 115.323

Both builds use the same lexer/reader source and benchmark harness. The optimized runtime scans framed words with bounded SSE2 blocks and quotes with libc's memchr, borrows numeric spans during synchronous parsing, skips reader arenas for standalone scalar words, and avoids initializing a compound nesting stack for scalar frames. Generated C confirmed that write-char borrows four stack bytes without a string or heap array allocation. A final 15-sample run with file-controller/readiness support measured 2.439/24.437/0.750/167.026/118.984 ms for these five cases respectively. These are a separate run; use the alternating table for controlled comparisons.

-d vile_scalar selects portable scalar framing helpers. Correctness tests cover all word delimiters at block boundaries and split string/backslash/UTF-8 input. The lexer and reader implementations are not changed by this runtime work.