summaryrefslogtreecommitdiffstats
path: root/bench
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-10-10 11:14:18 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-10-10 11:14:18 -0400
commit20cf56fd225d341ab1ae1c6924e73b7e28583b1c (patch)
treef0b810f128d3f0c9297676e2ad63e620414d4762 /bench
parent5e1d22f464fa6ded047dcfecbd93dce7a088a4f3 (diff)
downloadbfs-20cf56fd225d341ab1ae1c6924e73b7e28583b1c.tar.xz
bench: Allow format specifiers in (sub)group headers
Diffstat (limited to 'bench')
-rw-r--r--bench/bench.sh20
1 files changed, 10 insertions, 10 deletions
diff --git a/bench/bench.sh b/bench/bench.sh
index 09564ac..e0943d4 100644
--- a/bench/bench.sh
+++ b/bench/bench.sh
@@ -266,17 +266,17 @@ do-hyperfine() {
# Print the header for a benchmark group
group() {
- printf '## %s\n\n' "$1" | tee -a "$BENCH_DIR/bench.md"
+ printf "## $1\\n\\n" "${@:2}" | tee -a "$BENCH_DIR/bench.md"
}
# Print the header for a benchmark subgroup
subgroup() {
- printf '### %s\n\n' "$1" | tee -a "$BENCH_DIR/bench.md"
+ printf "### $1\\n\\n" "${@:2}" | tee -a "$BENCH_DIR/bench.md"
}
# Print the header for a benchmark sub-subgroup
subsubgroup() {
- printf '#### %s\n\n' "$1" | tee -a "$BENCH_DIR/bench.md"
+ printf "#### $1\\n\\n" "${@:2}" | tee -a "$BENCH_DIR/bench.md"
}
# Benchmark the complete traversal of a directory tree
@@ -284,7 +284,7 @@ subsubgroup() {
bench-complete-corpus() {
total=$(./bin/bfs "$2" -printf '.' | wc -c)
- subgroup "$1 ($total files)"
+ subgroup "%s (%'d files)" "$1" "$total"
cmds=()
for bfs in "${BFS[@]}"; do
@@ -318,14 +318,14 @@ bench-early-quit-corpus() {
dir="$2"
max_depth=$(./bin/bfs "$dir" -printf '%d\n' | sort -rn | head -n1)
- subgroup "$1 (depth $max_depth)"
+ subgroup '%s (depth %d)' "$1" "$max_depth"
# Save the list of unique filenames, along with their depth
UNIQ="$BENCH_DIR/uniq"
./bin/bfs "$dir" -printf '%d %f\n' | sort -k2 | uniq -uf1 >"$UNIQ"
for ((i = 2; i <= max_depth; i *= 2)); do
- subsubgroup "Depth $i"
+ subsubgroup 'Depth %d' "$i"
# Sample random uniquely-named files at depth $i
export FILES="$BENCH_DIR/uniq-$i"
@@ -364,7 +364,7 @@ bench-early-quit() {
# Benchmark printing paths without colors
bench-print-nocolor() {
- subsubgroup "$1"
+ subsubgroup '%s' "$1"
cmds=()
for bfs in "${BFS[@]}"; do
@@ -384,7 +384,7 @@ bench-print-nocolor() {
# Benchmark printing paths with colors
bench-print-color() {
- subsubgroup "$1"
+ subsubgroup '%s' "$1"
cmds=()
for bfs in "${BFS[@]}"; do
@@ -417,10 +417,10 @@ bench-print() {
# Benchmark search strategies
bench-strategies-corpus() {
- subgroup "$1"
+ subgroup '%s' "$1"
for bfs in "${BFS[@]}"; do
- subsubgroup "$bfs"
+ subsubgroup '%s' "$bfs"
cmds=("$bfs -S "{bfs,dfs,ids,eds}" $2")
do-hyperfine "${cmds[@]}"
done