Add benchmark script
* Structure `cli` crate as both a library and an executable, so that benchmarks can import code from the crate. * Import macros in the Rust 2018 style.
This commit is contained in:
parent
e26cbb62a5
commit
4cac85fec4
25 changed files with 244 additions and 92 deletions
|
|
@ -6,7 +6,7 @@ function usage {
|
|||
cat <<-EOF
|
||||
USAGE
|
||||
|
||||
$0 [-Ld] [-l language-name] [-f example-file-name]
|
||||
$0 [-h] [-l language-name] [-e example-file-name]
|
||||
|
||||
OPTIONS
|
||||
|
||||
|
|
@ -14,63 +14,24 @@ OPTIONS
|
|||
|
||||
-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
|
||||
|
||||
-b run make under the scan-build static analyzer
|
||||
-e run only the benchmarks that parse the example file with the given name
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ "$(uname -s)" == "Darwin" ]; then
|
||||
export LINK="clang++ -fsanitize=address"
|
||||
fi
|
||||
|
||||
mode=normal
|
||||
export BUILDTYPE=Release
|
||||
cmd=out/$BUILDTYPE/benchmarks
|
||||
run_scan_build=
|
||||
|
||||
while getopts "bdhf:l:SL" option; do
|
||||
while getopts "hl:e:" option; do
|
||||
case ${option} in
|
||||
h)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
d)
|
||||
mode=debug
|
||||
;;
|
||||
f)
|
||||
export TREE_SITTER_BENCHMARK_FILE_NAME=${OPTARG}
|
||||
e)
|
||||
export TREE_SITTER_BENCHMARK_EXAMPLE_FILTER=${OPTARG}
|
||||
;;
|
||||
l)
|
||||
export TREE_SITTER_BENCHMARK_LANGUAGE=${OPTARG}
|
||||
;;
|
||||
L)
|
||||
export TREE_SITTER_BENCHMARK_LOG=1
|
||||
;;
|
||||
b)
|
||||
run_scan_build=true
|
||||
export TREE_SITTER_BENCHMARK_LANGUAGE_FILTER=${OPTARG}
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -n "$run_scan_build" ]]; then
|
||||
. script/util/scan-build.sh
|
||||
scan_build make -j2 benchmarks
|
||||
else
|
||||
make -j2 benchmarks
|
||||
fi
|
||||
|
||||
case $mode in
|
||||
debug)
|
||||
lldb $cmd
|
||||
;;
|
||||
|
||||
normal)
|
||||
exec $cmd
|
||||
;;
|
||||
esac
|
||||
cargo bench
|
||||
|
|
|
|||
3
script/benchmark.cmd
Normal file
3
script/benchmark.cmd
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
@echo off
|
||||
|
||||
cargo bench
|
||||
Loading…
Add table
Add a link
Reference in a new issue