2017-06-21 17:26:52 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
2017-07-05 17:27:32 -07:00
|
|
|
function usage {
|
|
|
|
|
cat <<-EOF
|
|
|
|
|
USAGE
|
|
|
|
|
|
|
|
|
|
$0 [-Ld] [-l language-name] [-f example-file-name]
|
|
|
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
|
|
|
|
|
|
-h print this message
|
|
|
|
|
|
|
|
|
|
-l run only the benchmarks for the given language
|
|
|
|
|
|
|
|
|
|
-f run only the benchmarks that parse the file with the given name
|
|
|
|
|
|
|
|
|
|
-d run tests in a debugger (either lldb or gdb)
|
|
|
|
|
|
|
|
|
|
-L run benchmarks with parse logging turned on
|
|
|
|
|
|
2017-07-06 10:22:14 -07:00
|
|
|
-b run make under the scan-build static analyzer
|
|
|
|
|
|
2017-07-05 17:27:32 -07:00
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [ "$(uname -s)" == "Darwin" ]; then
|
|
|
|
|
export LINK="clang++ -fsanitize=address"
|
|
|
|
|
fi
|
|
|
|
|
|
2017-06-21 17:26:52 -07:00
|
|
|
mode=normal
|
2017-07-06 11:49:32 -07:00
|
|
|
export BUILDTYPE=Release
|
|
|
|
|
cmd=out/$BUILDTYPE/benchmarks
|
2017-07-06 10:22:14 -07:00
|
|
|
run_scan_build=
|
2017-06-21 17:26:52 -07:00
|
|
|
|
2017-07-06 10:22:14 -07:00
|
|
|
while getopts "bdhf:l:SL" option; do
|
2017-06-21 17:26:52 -07:00
|
|
|
case ${option} in
|
2017-07-05 17:27:32 -07:00
|
|
|
h)
|
|
|
|
|
usage
|
|
|
|
|
exit
|
|
|
|
|
;;
|
2017-06-21 17:26:52 -07:00
|
|
|
d)
|
|
|
|
|
mode=debug
|
|
|
|
|
;;
|
|
|
|
|
f)
|
|
|
|
|
export TREE_SITTER_BENCHMARK_FILE_NAME=${OPTARG}
|
|
|
|
|
;;
|
|
|
|
|
l)
|
|
|
|
|
export TREE_SITTER_BENCHMARK_LANGUAGE=${OPTARG}
|
|
|
|
|
;;
|
|
|
|
|
L)
|
|
|
|
|
export TREE_SITTER_BENCHMARK_LOG=1
|
|
|
|
|
;;
|
2017-07-06 10:22:14 -07:00
|
|
|
b)
|
|
|
|
|
run_scan_build=true
|
|
|
|
|
;;
|
2017-06-21 17:26:52 -07:00
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2017-07-06 10:22:14 -07:00
|
|
|
if [[ -n "$run_scan_build" ]]; then
|
2017-07-06 10:32:41 -07:00
|
|
|
. script/util/scan-build.sh
|
2017-07-06 12:36:57 -07:00
|
|
|
scan_build make -j2 benchmarks
|
2017-07-06 10:22:14 -07:00
|
|
|
else
|
|
|
|
|
make -j2 benchmarks
|
|
|
|
|
fi
|
2017-07-05 17:27:32 -07:00
|
|
|
|
2017-06-21 17:26:52 -07:00
|
|
|
case $mode in
|
|
|
|
|
debug)
|
|
|
|
|
lldb $cmd
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
normal)
|
|
|
|
|
exec $cmd
|
|
|
|
|
;;
|
|
|
|
|
esac
|