Skip to content

perf(coverage): collapse is_executable_line grep calls#643

Merged
Chemaclass merged 1 commit intomainfrom
feat/636-speed-up-coverage-report-generation
Apr 29, 2026
Merged

perf(coverage): collapse is_executable_line grep calls#643
Chemaclass merged 1 commit intomainfrom
feat/636-speed-up-coverage-report-generation

Conversation

@Chemaclass
Copy link
Copy Markdown
Member

🤔 Background

Related #636

Coverage report generation runs bashunit::coverage::is_executable_line on every line of every tracked source file. The previous implementation issued up to seven grep subshells per line, which dominates runtime on slow shells (e.g. Cygwin on legacy hardware where users observed multi-hour runs).

💡 Changes

  • Combine the seven non-executable line patterns into a single pre-compiled alternation regex matched in one grep invocation.
  • Keep each alternation self-anchored so all existing semantics (comments, function decls, brace-only, control flow keywords, done with redirection/pipe/fd, case patterns, standalone )) are preserved.
  • Retain the empty/whitespace-only fast path as a built-in parameter expansion check (no subshell).
  • Reporter measured ~3.8x faster coverage generation; existing coverage_executable_test.sh suite passes unchanged.

Combine the seven per-pattern grep subshells in
bashunit::coverage::is_executable_line into a single combined regex,
matched in one grep invocation per line. Each alternation stays
self-anchored so the existing semantics (and the existing test suite)
hold unchanged.

Reporter measured ~3.8x faster coverage generation on slow hardware.

Closes #636
@Chemaclass Chemaclass added the enhancement New feature or request label Apr 29, 2026
@Chemaclass Chemaclass self-assigned this Apr 29, 2026
@Chemaclass Chemaclass merged commit 894e4e0 into main Apr 29, 2026
48 of 49 checks passed
@Chemaclass Chemaclass deleted the feat/636-speed-up-coverage-report-generation branch April 29, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant