Skip to content

test(bench): benchmark indexing in long strings 馃У - #222

Merged
timfennis merged 1 commit into
masterfrom
test/string-index-benchmarks
Sep 8, 2026
Merged

test(bench): benchmark indexing in long strings 馃У#222
timfennis merged 1 commit into
masterfrom
test/string-index-benchmarks

Conversation

@timfennis

Copy link
Copy Markdown
Owner

String indexing currently scans UTF-8 codepoints, but the benchmark suite had no coverage for reads from long strings. Add ASCII and Unicode programs that each perform 10,000 reads across the final four positions of a 131,072-codepoint string. The Unicode case mixes 1-, 2-, 3-, and 4-byte codepoints.

Both programs build the string by doubling, check the accumulated result, and are automatically picked up by the existing Criterion runner. They also work with bench.sh.

A local 10-sample Criterion run measured approximately 120 ms for ASCII and 298 ms for Unicode per program execution, including setup and interpreter overhead.

Validation:

  • cargo fmt --all
  • cargo test --workspace --quiet
  • cargo bench -p benches --bench benchmark -- string_index --sample-size 10 --warm-up-time 1 --measurement-time 1

AI disclosure: Codex authored the benchmark programs and this PR description.

@timfennis
timfennis merged commit faaae70 into master Sep 8, 2026
1 check passed
@timfennis
timfennis deleted the test/string-index-benchmarks branch September 8, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant