Parsing a schema or document can be a critical part of the application, especially if you have to care about latency. This is the case for proxies or caches where high load is expected. This benchmark should outline good candidates. We use the libraries as documented in tests or documentation. We don't tune a specific parser. We assume that a new query arrives the parser at any time.
This test requires Rust, Go and Node.js (>=14)
Parsing a schema
Parse the gitlab schema. The schema has a size of around
./bench.sh ./../schema.graphql schema
✅graphqljs (warmed): 11.1135ms
✅graphqljs (cold): 39.505ms
Compared to different aspect like accessibility and maintainability
async-graphql-parser is the overall winner. It uses a PEG grammar as input.
Parsing a query
Parse the kitchen-sink document. The document has a size of around
1KB but with a wide usage of the specification.
./bench.sh ./../kitchen-sink.graphql query
✅graphqljs (warmed): 0.2104ms
✅graphqljs (cold): 1.4962ms
graphql-parser wins! Alarming that some popular parser can not even parse the query.
Feel free to improve or add another parser to the list. PR's are welcome!