All Projects → StarpTech → graphql-parser-bench

StarpTech / graphql-parser-bench

Licence: MIT license
GraphQL parser comparison in different languages

Programming Languages

go
31211 projects - #10 most used programming language
rust
11053 projects
shell
77523 projects
javascript
184084 projects - #8 most used programming language

graphql-parser-bench

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.

Benchmark

This test requires Rust, Go and Node.js (>=14)

Intermediate result

Parsing a schema

Parse the gitlab schema. The schema has a size of around 671KB.

./bench.sh ./../schema.graphql schema
  • graphql-go-tools: 5.7179ms
  • graphql-parser: 7.4608ms
  • gqlparser: 7.7642ms
  • async-graphql-parser: 12.7027ms
  • graphqljs (warmed): 11.1135ms
  • graphqljs (cold): 39.505ms
  • go-graphql: Error

🏆 Winner: In terms of speed graphql-go-tools wins!

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
  • graphql-parser: 20.9µs
  • gqlparser: 38.8µs
  • graphql-go-tools: 42.6µs
  • graphqljs (warmed): 0.2104ms
  • graphqljs (cold): 1.4962ms
  • async-graphql-parser: Error
  • go-graphql: Error

🏆 Winner: In terms of speed graphql-parser wins! Alarming that some popular parser can not even parse the query.

Contribute

Feel free to improve or add another parser to the list. PR's are welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].