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.
This commit is contained in:
Max Brunsfeld 2017-06-21 17:26:52 -07:00
parent 298228d8de
commit 17bc3dfaf7
11 changed files with 191 additions and 11 deletions

42
script/benchmark Executable file
View file

@ -0,0 +1,42 @@
#!/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

View file

@ -7,3 +7,4 @@ set -e
script/fetch-fixtures
script/check-mallocs
script/test -b
script/benchmark