Skip to content

perf(runner): auto-skip per-test timing when the clock forks an interpreter#769

Merged
Chemaclass merged 1 commit into
mainfrom
perf/765-clock-skip
Jul 11, 2026
Merged

perf(runner): auto-skip per-test timing when the clock forks an interpreter#769
Chemaclass merged 1 commit into
mainfrom
perf/765-clock-skip

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #765

On shells without a native sub-second clock (Bash 3.2 on macOS), bashunit::clock::now falls back to forking a perl interpreter, so every test pays two perl forks just to measure a duration that a plain run then discards.

💡 Changes

  • Default BASHUNIT_SHOW_EXECUTION_TIME to auto: per-test times show when the clock is fork-free and hide when measuring would fork an interpreter.
  • Skip both per-test clock reads unless a consumer needs the number (--profile, --verbose, a report, or an explicit execution-time display).
  • Keep the total "Time taken" footer visible in auto; only false hides it.
  • Zero behavior change on cheap-clock platforms (Bash 5 / Linux CI); documented in the CHANGELOG, docs, and ADR-008.

…preter (#765)

Default BASHUNIT_SHOW_EXECUTION_TIME to `auto`: measure per-test duration
only when a consumer needs it (--profile, --verbose, a report, or an
explicit execution-time display). On shells whose clock forks an
interpreter (Bash 3.2 macOS -> perl), a plain run now skips both clock
reads, removing ~2 perl forks per test.

- clock::is_expensive classifies the resolved impl (perl/python/node/
  powershell = expensive)
- env::is_show_execution_time_enabled resolves auto via the clock cost;
  env::is_total_execution_time_enabled keeps the footer visible unless
  explicitly false
- runner::needs_test_duration gates the clock reads behind the single
  set of duration consumers
- reports::is_enabled extracted so the predicate can reuse it

See adrs/adr-008-auto-skip-per-test-timing.md
@Chemaclass Chemaclass added the enhancement New feature or request label Jul 11, 2026
@Chemaclass Chemaclass self-assigned this Jul 11, 2026
@Chemaclass Chemaclass merged commit ba135df into main Jul 11, 2026
31 checks passed
@Chemaclass Chemaclass deleted the perf/765-clock-skip branch July 11, 2026 13:26
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