Files
sed/util/bench-compare.sh
T
2025-05-25 15:16:21 +03:00

31 lines
695 B
Bash
Executable File

#!/bin/sh
#
# Compare the results of two benchmarks reporting fastest for each task
#
set -eu
if [ $# -ne 2 ] ; then
echo "Usage: $(basename $0) results-1 results-2" 1>&2
exit 1
fi
paste -d , "$1" "$2" |
sed "s/^/$1,$2,/" |
awk -F, 'FNR != 1 {
printf("%22s ", $3);
if (!$4)
printf("%12s encountered an error\n", $1);
else if (!$12)
printf("%12s encountered an error\n", $2);
else if ($4 / $12 > 1.01)
printf("%12s is %5.2f times faster than %s\n", $2, $4 / $12, $1);
else if ($12 / $4 > 1.01)
printf("%12s is %5.2f times faster than %s\n", $1, $12 / $4, $2);
else
printf("%12s is similarly fast as %s\n", $1, $2);
}'