Context
src/runner.sh contains ~98 $(...) command substitutions. Many sit in the per-test hot path, forking a subshell on every test execution. Suite runs ~80s sync / ~22s parallel; subshell overhead is a sizable chunk.
Hot-path offenders
bashunit::runner::extract_encoded_field (src/runner.sh:49) — called per field per test
bashunit::runner::extract_subshell_type (src/runner.sh:78)
bashunit::runner::format_subshell_output (src/runner.sh:84)
bashunit::runner::compute_total_assertions (src/runner.sh:62)
Param expansion already used in places — push further. Common pattern:
foo=$(bashunit::runner::extract_subshell_type "$out")
Refactor to fill an outvar (Bash-3 safe via eval or namref-free assignment) instead of capturing subshell stdout:
bashunit::runner::extract_subshell_type out "$subshell_output"
# function body: eval "$1=\"\${2%%]*}\""; eval "$1=\"\${$1#[}\""
Or inline the param expansions at call sites where the helper is one-liner.
Acceptance
Notes
- Pre-compiled regex
_BASHUNIT_RUNNER_PARSE_RESULT_REGEX (runner.sh:5) already exists — extend usage if it reduces helper calls.
- Validate with
PS4='+ \$EPOCHREALTIME ' bash -x ./bashunit tests/unit/<file>.sh 2>trace to confirm hotspots pre/post.
Context
src/runner.shcontains ~98$(...)command substitutions. Many sit in the per-test hot path, forking a subshell on every test execution. Suite runs ~80s sync / ~22s parallel; subshell overhead is a sizable chunk.Hot-path offenders
bashunit::runner::extract_encoded_field(src/runner.sh:49) — called per field per testbashunit::runner::extract_subshell_type(src/runner.sh:78)bashunit::runner::format_subshell_output(src/runner.sh:84)bashunit::runner::compute_total_assertions(src/runner.sh:62)Param expansion already used in places — push further. Common pattern:
foo=$(bashunit::runner::extract_subshell_type "$out")Refactor to fill an outvar (Bash-3 safe via eval or namref-free assignment) instead of capturing subshell stdout:
Or inline the param expansions at call sites where the helper is one-liner.
Acceptance
$(...)capture in per-test hot path ofrunner.shfor the listed helpers./bashunit tests/)./bashunit --parallel tests/)declare -n)tests/unit/posted in PRNotes
_BASHUNIT_RUNNER_PARSE_RESULT_REGEX(runner.sh:5) already exists — extend usage if it reduces helper calls.PS4='+ \$EPOCHREALTIME ' bash -x ./bashunit tests/unit/<file>.sh 2>traceto confirm hotspots pre/post.