2019-11-27 23:21:11 +08:00
|
|
|
#!/bin/sh
|
2019-04-11 05:02:21 +08:00
|
|
|
|
2020-09-22 01:52:00 +08:00
|
|
|
if [ "$#" -gt 2 -o "$#" -eq 0 ]; then
|
|
|
|
echo "Usage: driver.sh /path/to/fish [/path/to/other/fish]"
|
|
|
|
exit 1
|
2019-04-11 05:02:21 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
FISH_PATH=$1
|
2020-09-22 01:52:00 +08:00
|
|
|
FISH2_PATH=$2
|
2019-04-11 05:02:21 +08:00
|
|
|
BENCHMARKS_DIR=$(dirname "$0")/benchmarks
|
|
|
|
|
2021-12-19 18:08:18 +08:00
|
|
|
quote() {
|
|
|
|
# Single-quote the given string for a POSIX shell, except in common cases that don't need it.
|
|
|
|
printf %s "$1" |
|
|
|
|
sed "/[^[:alnum:]\/.-]/ {
|
|
|
|
s/'/'\\\''/g
|
|
|
|
s/^/'/
|
|
|
|
s/\$/'/
|
|
|
|
}"
|
|
|
|
}
|
|
|
|
|
2019-04-11 05:02:21 +08:00
|
|
|
for benchmark in "$BENCHMARKS_DIR"/*; do
|
2019-11-28 09:49:21 +08:00
|
|
|
basename "$benchmark"
|
2022-09-25 19:22:52 +08:00
|
|
|
# If we have hyperfine, use it first to warm up the cache
|
2019-11-27 23:21:11 +08:00
|
|
|
if command -v hyperfine >/dev/null 2>&1; then
|
2022-09-24 19:34:53 +08:00
|
|
|
cmd1="$(quote "${FISH_PATH}") --no-config $(quote "$benchmark")"
|
2020-09-22 01:52:00 +08:00
|
|
|
if [ -n "$FISH2_PATH" ]; then
|
2022-09-24 19:34:53 +08:00
|
|
|
cmd2="$(quote "${FISH2_PATH}") --no-config $(quote "$benchmark")"
|
2022-09-25 19:22:52 +08:00
|
|
|
hyperfine --warmup 3 "$cmd1" "$cmd2"
|
2020-09-22 01:52:00 +08:00
|
|
|
else
|
2022-09-25 19:22:52 +08:00
|
|
|
hyperfine --warmup 3 "$cmd1"
|
2020-09-22 01:52:00 +08:00
|
|
|
fi
|
2019-11-27 03:10:04 +08:00
|
|
|
fi
|
2022-09-25 19:22:52 +08:00
|
|
|
|
|
|
|
[ -n "$FISH2_PATH" ] && echo "$FISH_PATH"
|
|
|
|
"${FISH_PATH}" --print-rusage-self "$benchmark" > /dev/null
|
|
|
|
if [ -n "$FISH2_PATH" ]; then
|
|
|
|
echo "$FISH2_PATH"
|
|
|
|
"${FISH2_PATH}" --print-rusage-self "$benchmark" > /dev/null
|
|
|
|
fi
|
|
|
|
|
2019-04-11 05:02:21 +08:00
|
|
|
done
|
|
|
|
|