Problem
The HTML report's per-file loop pays three command substitutions per page:
stats=$(bashunit::coverage::get_cached_stats "$file")local display_file="${file#"$(pwd)"/}"
safe_filename=$(bashunit::coverage::path_to_filename "$file")and path_to_filename contains its own $(pwd), so it is really four. At 129
pages that is ~500 forks for a cached array read, a string prefix strip and two
parameter substitutions.
Measured: 129 × $(pwd) is 74 ms against 7 ms for $PWD, and 387 command
substitutions cost 204 ms.
Fix
Return-slot variants — cached_stats_to_slots filling the four split slots
split_stats already defines, and path_to_filename_to_slot — with the
stdout-returning versions kept for other callers. $PWD in place of $(pwd).
Result: 3393 ms → 3130 ms for a 128-file report (~8%), output identical.
Problem
The HTML report's per-file loop pays three command substitutions per page:
and
path_to_filenamecontains its own$(pwd), so it is really four. At 129pages that is ~500 forks for a cached array read, a string prefix strip and two
parameter substitutions.
Measured: 129 ×
$(pwd)is 74 ms against 7 ms for$PWD, and 387 commandsubstitutions cost 204 ms.
Fix
Return-slot variants —
cached_stats_to_slotsfilling the four split slotssplit_statsalready defines, andpath_to_filename_to_slot— with thestdout-returning versions kept for other callers.
$PWDin place of$(pwd).Result: 3393 ms → 3130 ms for a 128-file report (~8%), output identical.