Skip to content

docs(assert): quantify what assert_matches costs - #1188

Merged
Chemaclass merged 1 commit into
mainfrom
docs/1187-assert-matches-cost
Aug 13, 2026
Merged

docs(assert): quantify what assert_matches costs#1188
Chemaclass merged 1 commit into
mainfrom
docs/1187-assert-matches-cost

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1187

assertion count wall per call
assert_same 2000 ~130 ms 0.065 ms
assert_contains 2000 ~180 ms 0.09 ms
assert_matches 500 ~1.25 s 2.5 ms (~38x)

Stable across three runs each.

The grep -E fork behind it is deliberate and stays: Bash 3.2 changed
whether a quoted right-hand side of [[ =~ ]] is a regex or a literal, so at
the Bash 3.0 floor removing it means breaking one semantic or the other.
perf-fork-budget.md already recorded that reasoning — what it never recorded
is the price, which left the trade asserted rather than weighable.

💡 Changes

  • Quantify the cost in the internal rule
  • Tell users, who had no way to know a hot loop pays 38x, and point at assert_contains when the pattern is a fixed substring
  • Tip appended at section end so the CLI doc output keeps its existing content; the doc snapshot is byte-identical

Measured, stable over three runs each:

  assert_same      2000 calls  ~130ms   0.065ms each
  assert_contains  2000 calls  ~180ms   0.09ms each
  assert_matches    500 calls  ~1.25s   2.5ms each (~38x)

The grep -E fork behind that is deliberate and stays: Bash 3.2 changed whether
a quoted right-hand side of [[ =~ ]] is a regex or a literal, so at the 3.0
floor removing it means breaking one semantic or the other. perf-fork-budget.md
already said so -- what it never said is the price, which left the trade
asserted rather than weighable.

Also tells users, who had no way to know a hot loop pays 38x, and points at
assert_contains when the pattern is a fixed substring.

The tip is appended at the end of the section: the bashunit doc renderer
truncates a section, so inserting earlier drops existing content from CLI
output. Doc snapshot is byte-identical.

Closes #1187
@Chemaclass Chemaclass added the documentation Improvements or additions to documentation label Aug 13, 2026
@Chemaclass Chemaclass self-assigned this Aug 13, 2026
@Chemaclass
Chemaclass merged commit 72a53ab into main Aug 13, 2026
6 checks passed
@Chemaclass
Chemaclass deleted the docs/1187-assert-matches-cost branch August 13, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant