From a4cee5127d91eeb5aab24bb23c04cdb451639982 Mon Sep 17 00:00:00 2001 From: Diomidis Spinellis Date: Sat, 24 May 2025 16:15:24 +0300 Subject: [PATCH] Handle failed executions --- util/bench-compare.sh | 6 +++++- util/benchmark.sh | 12 ++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/util/bench-compare.sh b/util/bench-compare.sh index da0fe27..0ee61b8 100755 --- a/util/bench-compare.sh +++ b/util/bench-compare.sh @@ -17,7 +17,11 @@ paste -d , "$1" "$2" | awk -F, 'FNR != 1 { printf("%22s ", $3); - if ($4 / $12 > 1.1) + if (!$4) + printf("%12s encountered an error\n", $1); + else if (!$12) + printf("%12s encountered an error\n", $2); + else if ($4 / $12 > 1.1) printf("%12s is %5.1f times faster than %s\n", $2, $4 / $12, $1); else if ($12 / $4 > 1.1) printf("%12s is %5.1f times faster than %s\n", $1, $12 / $4, $2); diff --git a/util/benchmark.sh b/util/benchmark.sh index ddade41..ebbb02a 100755 --- a/util/benchmark.sh +++ b/util/benchmark.sh @@ -22,14 +22,18 @@ SCRIPTS=tests/fixtures/sed/script # Run hyperfine with the specified name and command and collect the results. bench_run() { - hyperfine --command-name "$1" --warmup 2 --export-csv out.csv "$2" - - # Append the results sans-heading - sed 1d out.csv >>"$OUT" + if hyperfine --command-name "$1" --warmup 2 --export-csv out.csv "$2" ; then + # Output the results sans-heading. + sed 1d out.csv >>"$OUT" + else + # Unable to run; output a named empty record. + echo "$1,,,,,,," >>"$OUT" + fi rm out.csv } +# Shared heading echo 'command,mean,stddev,median,user,system,min,max' >"$OUT" # Short line processing