Closed maxbrunsfeld closed 8 years ago
Also, this makes it easy to see that LR parsing time is pretty much linear in the length of the input:
# repeat jquery.js 10 times
$ for i in $(seq 1 10); do cat /tmp/jquery.js >> /tmp/jquery-x10.js; done
# repeat jquery.js 100 times
$ for i in $(seq 1 100); do cat /tmp/jquery.js >> /tmp/jquery-x100.js; done
# parse the three files
$ tree-sitter parse /tmp/jquery.js
Parsed in 45 milliseconds
$ tree-sitter parse /tmp/jquery-x10.js
Parsed in 407 milliseconds
$ tree-sitter parse /tmp/jquery-x100.js
Parsed in 4144 milliseconds
One useful finding from this is that the recursive functions
ts_tree_assign_parents
andts_tree_release
can use a lot of stack frames (I cut off the top of the graph to make it fit better here). This is probably a security risk for the library. Those functions probably need to be optimized in that regard.