tree-sitter/script/benchmark
Max Brunsfeld 17bc3dfaf7 Add a benchmark command
This command measures the speed of parsing each grammar's examples.
It also uses each grammar to parse all of the *other* grammars' examples
in order to measure error recovery performance with fairly large files.
2017-07-05 14:14:38 -07:00

42 lines
609 B
Bash
Executable file

#!/usr/bin/env bash
set -e
mode=normal
make -j2 benchmarks
cmd=out/release/benchmarks
while getopts "df:l:SL" option; do
case ${option} in
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
;;
S)
mode=SVG
export TREE_SITTER_BENCHMARK_SVG=1
;;
esac
done
case $mode in
debug)
lldb $cmd
;;
SVG)
$cmd 2> >(grep -v 'Assertion failed' > test.dot)
;;
normal)
exec $cmd
;;
esac