Problem
--coverage-report-html over this repo's src takes 58.7 seconds for 128
files (129 pages) — about 458 ms per page. Every other renderer is now under
300 ms for the same input (#1088, #1090, #1092).
The cause is one line of the per-line loop in html_file.sh:
escaped_line=$(bashunit::coverage::html_escape "$line")
and the helper itself:
printf"%s""$text"| sed "s/&/\&/g; s/</\</g; s/>/\>/g"
That is a command substitution and a sed per source line — roughly 22,000
processes for this repo's ~11,000 tracked lines. The tooltip path adds a
basename fork per test that hit a line.
Fix
Escape in Bash into a return slot. Measured on one 413-line file:
| 413 lines |
|---|
printf | sed in $() | 877 ms |
| pure-bash slot | 12 ms |
Byte-identical over 5,790 real source lines. ${var//…} is quadratic on large
strings, but these are single source lines, which is where it wins.
basename in the tooltip loop becomes ${test_file##*/} for the same reason.
Why it matters
The HTML report is the one a human looks at, and a minute per run is the
difference between using it and not. A 500-file project pays four.
Problem
--coverage-report-htmlover this repo'ssrctakes 58.7 seconds for 128files (129 pages) — about 458 ms per page. Every other renderer is now under
300 ms for the same input (#1088, #1090, #1092).
The cause is one line of the per-line loop in
html_file.sh:escaped_line=$(bashunit::coverage::html_escape "$line")and the helper itself:
That is a command substitution and a
sedper source line — roughly 22,000processes for this repo's ~11,000 tracked lines. The tooltip path adds a
basenamefork per test that hit a line.Fix
Escape in Bash into a return slot. Measured on one 413-line file:
printf | sedin$()Byte-identical over 5,790 real source lines.
${var//…}is quadratic on largestrings, but these are single source lines, which is where it wins.
basenamein the tooltip loop becomes${test_file##*/}for the same reason.Why it matters
The HTML report is the one a human looks at, and a minute per run is the
difference between using it and not. A 500-file project pays four.