A JSON Parser was implemented using each of these Parsing Libraries (Generators/Combinators/DSLs):
Chevrotain Parsing DSL implementation
Parsimmon Parser Combinator implementation
ANTLR4 Parser Generator grammar -> generated code
Myna Parsing Library implementation
PEG.js Parser Generator grammar -> generated code
Jison parser Generator grammar -> generated code
Nearley Parser Generator grammar -> generated code with Moo Lexer
The JSON Grammar was used because it is simple to implement, simple to compare and is often already available as a sample grammar for most parsing tools.
The input sample for the benchmark is a ~1,000 lines JSON file generated by json-generator.
See the benchmark methodology for details on what is being tested and how.
The Chevrotain and Antlr Libraries can either produce a Parse Tree (with Visitor / listener) or use embedded actions in the grammar. Thus they are measured in both scenarios ("-PT" means Parse Tree variant).
Benchmarking is done using the benchmark.js library.
The entire source code for this benchmark can be found in this github repository.