docs(assert): quantify what assert_matches costs - #1188
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 Background
Related #1187
assert_sameassert_containsassert_matchesStable across three runs each.
The
grep -Efork behind it is deliberate and stays: Bash 3.2 changedwhether a quoted right-hand side of
[[ =~ ]]is a regex or a literal, so atthe Bash 3.0 floor removing it means breaking one semantic or the other.
perf-fork-budget.mdalready recorded that reasoning — what it never recordedis the price, which left the trade asserted rather than weighable.
💡 Changes
assert_containswhen the pattern is a fixed substring