2017-06-21 17:26:52 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
2017-07-05 17:27:32 -07:00
|
|
|
function usage {
|
2024-03-28 17:33:55 +02:00
|
|
|
cat <<EOF
|
2017-07-05 17:27:32 -07:00
|
|
|
USAGE
|
|
|
|
|
|
2019-08-02 12:01:35 -07:00
|
|
|
$0 [-h] [-l language-name] [-e example-file-name] [-r repetition-count]
|
2017-07-05 17:27:32 -07:00
|
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
|
|
|
|
|
|
-h print this message
|
|
|
|
|
|
|
|
|
|
-l run only the benchmarks for the given language
|
|
|
|
|
|
2019-02-01 14:39:37 -08:00
|
|
|
-e run only the benchmarks that parse the example file with the given name
|
2017-07-06 10:22:14 -07:00
|
|
|
|
2019-08-02 12:01:35 -07:00
|
|
|
-r parse each sample the given number of times (default 5)
|
|
|
|
|
|
2020-06-26 15:05:27 -07:00
|
|
|
-g debug
|
|
|
|
|
|
2017-07-05 17:27:32 -07:00
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-26 15:05:27 -07:00
|
|
|
mode=normal
|
|
|
|
|
|
|
|
|
|
while getopts "hgl:e:r:" option; do
|
2017-06-21 17:26:52 -07:00
|
|
|
case ${option} in
|
2017-07-05 17:27:32 -07:00
|
|
|
h)
|
|
|
|
|
usage
|
|
|
|
|
exit
|
|
|
|
|
;;
|
2020-06-26 15:05:27 -07:00
|
|
|
g)
|
|
|
|
|
mode=debug
|
|
|
|
|
;;
|
2019-02-01 14:39:37 -08:00
|
|
|
e)
|
|
|
|
|
export TREE_SITTER_BENCHMARK_EXAMPLE_FILTER=${OPTARG}
|
2017-06-21 17:26:52 -07:00
|
|
|
;;
|
|
|
|
|
l)
|
2019-02-01 14:39:37 -08:00
|
|
|
export TREE_SITTER_BENCHMARK_LANGUAGE_FILTER=${OPTARG}
|
2017-07-06 10:22:14 -07:00
|
|
|
;;
|
2019-08-02 12:01:35 -07:00
|
|
|
r)
|
|
|
|
|
export TREE_SITTER_BENCHMARK_REPETITION_COUNT=${OPTARG}
|
|
|
|
|
;;
|
2024-03-28 17:33:55 +02:00
|
|
|
*)
|
|
|
|
|
usage
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
2017-06-21 17:26:52 -07:00
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2024-03-28 17:33:55 +02:00
|
|
|
if [[ $mode == debug ]]; then
|
2020-06-26 15:05:27 -07:00
|
|
|
test_binary=$(
|
2024-03-28 17:33:55 +02:00
|
|
|
cargo bench benchmark -p tree-sitter-cli --no-run --message-format=json 2> /dev/null |
|
2020-06-26 15:05:27 -07:00
|
|
|
jq -rs 'map(select(.target.name == "benchmark" and .executable))[0].executable'
|
|
|
|
|
)
|
|
|
|
|
env | grep TREE_SITTER
|
2024-03-28 17:33:55 +02:00
|
|
|
echo "$test_binary"
|
2020-06-26 15:05:27 -07:00
|
|
|
else
|
2021-02-05 11:55:54 -08:00
|
|
|
exec cargo bench benchmark -p tree-sitter-cli
|
2020-06-26 15:05:27 -07:00
|
|
|
fi
|