Skip to content

perf(tools): count inline test modules in a read outline, don't list them - #463

Merged
mrnasil merged 1 commit into
mainfrom
perf/outline-hide-test-mods
Nov 25, 2026
Merged

mrnasil merged 1 commit into
mainfrom
perf/outline-hide-test-mods

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 25, 2026

Copy link
Copy Markdown
Member

Why

A large Rust file is read as an outline of its declarations. In session.rs most of those are test names (fn load_fills_missing_message_timestamp_from_valid_and_invalid_rows, …), which a read rarely needs.

What

  • Declarations inside an inline #[cfg(test)] mod … { } body are left out and counted in the header: # outline: N declarations (+M in test modules, not listed) of L lines.
  • The #[cfg(test)] mod tests { line stays, so the model can read the range if it needs a test.
  • #[cfg(test)] mod x; and #[cfg(test)] fn are untouched. An unclosed module hides to end of file.
  • Rust only; other languages are unchanged.

Measured (release, Windows, o200k, bench_tokens.py, vs main with #460/#461)

Request 2 total Request 2 uncached Session total Session uncached
main 12,736 4,390 135,092 18,668
this PR 10,975 2,629 120,950 (−10%) 16,889

Checks

  • cargo test -p whycodes-tools --lib file:: (267 pass, new test covers closed / unclosed / mod x; / #[cfg(test)] fn)
  • fmt, clippy (tools), panic / swallowed-error / dependency / secrets ratchets

🤖 Generated with Claude Code

…them

A large Rust file read as an outline listed every declaration, and in a
file like session.rs most of them are test names. Declarations inside
an inline #[cfg(test)] mod { } are now counted in the header instead;
the mod line stays so a range read can still reach them.

bench_tokens.py: request 2 uncached 4,390 -> 2,629; session input
135,092 -> 120,950 (-10%).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mrnasil
mrnasil merged commit b4e2e66 into main Nov 25, 2026
7 checks passed
@mrnasil
mrnasil deleted the perf/outline-hide-test-mods branch November 25, 2026 00:18
@mrnasil mrnasil mentioned this pull request Nov 26, 2026
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