mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 18:03:37 +08:00
5211735965
I had only tested with a space in the path to the fish binary, but not with a space in the path to the repository. Closes #8559
42 lines
1.1 KiB
Bash
Executable File
42 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
if [ "$#" -gt 2 -o "$#" -eq 0 ]; then
|
|
echo "Usage: driver.sh /path/to/fish [/path/to/other/fish]"
|
|
exit 1
|
|
fi
|
|
|
|
FISH_PATH=$1
|
|
FISH2_PATH=$2
|
|
BENCHMARKS_DIR=$(dirname "$0")/benchmarks
|
|
|
|
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/\$/'/
|
|
}"
|
|
}
|
|
|
|
for benchmark in "$BENCHMARKS_DIR"/*; do
|
|
basename "$benchmark"
|
|
[ -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
|
|
|
|
if command -v hyperfine >/dev/null 2>&1; then
|
|
cmd1="$(quote "${FISH_PATH}") $(quote "$benchmark") > /dev/null"
|
|
if [ -n "$FISH2_PATH" ]; then
|
|
cmd2="$(quote "${FISH2_PATH}") $(quote "$benchmark") > /dev/null"
|
|
hyperfine "$cmd1" "$cmd2"
|
|
else
|
|
hyperfine "$cmd1"
|
|
fi
|
|
fi
|
|
done
|
|
|