perf(doc): parse assertion docs in a single awk pass#833
Merged
Conversation
bashunit::doc::print_asserts looped over all ~1.6k lines of docs/assertions.md and forked an 'echo | sed' pipe per line to detect headings, plus another sed per printed docstring line — ~3200 forks and ~5.1s wall to print a text file. The acceptance suite paid it ~7 times (snapshot + exit-code pairs and built-binary comparisons), making bashunit_test.sh a 29.7s file. One awk pass carries the identical logic (assert*/bashunit* heading gate, literal substring filter, bracket/anchor stripping, code-fence docstring emission): output is byte-identical (shasum-verified for 'doc' and 'doc equals', dev and built binary) and runs in ~50ms. bashunit_test.sh 29.7s -> 7.8s; full parallel suite ~24.5s -> ~16.5s. Fork-census regression test added (0 sed forks on the doc path). Closes #832
busybox awk (Alpine) rejects backslash-escaped brackets inside a bracket expression, so the link-bracket gsub silently matched nothing and doc output kept its markdown brackets. The []][ idiom is the portable spelling; output stays shasum-identical on macOS/GNU awk.
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 #832
bashunit doctook ~5.1s to print a text file: the doc parser forked anecho | sedpipe for every line of the ~1.6k-line assertion docs (plus asedper printed docstring line, ~3200 forks). The acceptance suite paid it ~7 times, making one test file 29.7s.💡 Changes
docanddoc equals, dev and built binary)bashunit doc~5.1s → ~50ms;bashunit_test.sh29.7s → 7.8s; full parallel suite ~24.5s → ~16.5sget_embedded_docs) untouchedhttps://claude.ai/code/session_01JSeB8UzLCpqst55hAK6dED