Skip to content

Commit

Permalink
perf(no-release): add benchmarks
Browse files Browse the repository at this point in the history
Added a couple of real-world-ish benchmarks with Sigma and Parjs:
- JSON parser.
- Tuple parser.
  • Loading branch information
norskeld committed Jan 24, 2022
1 parent cb208a2 commit fd39bb1
Show file tree
Hide file tree
Showing 16 changed files with 2,338 additions and 1 deletion.
29 changes: 29 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Benchmarks

Here you will find some benchmarks and rough performance comparison with similar libraries.

## Notes

Unfortunately, it's difficult to come up with sensible benchmarks, given that how a parser written with **sigma** depends entirely on what you are parsing, how you structure your parser(s), which patterns the parser attempts to match first, what is involved in constructing your AST (if any), and so on.

All that said, here are some rough numbers from the [JSON parsing benchmark][json-bench] (running on my MacBook Pro 16" with `Intel i9-9880H @ 2.30GHz` and `Node@14`).

```hs
Running "JSON :: sigma vs parjs" suite...

sigma: 582 ops/s, ±1.12% | fastest
parjs: 138 ops/s, ±1.38% | slowest, 76.29% slower
```

I have included results from [Sigma] and [Parjs] (another parser combinator library). I wanted to also add [Arcsecond], because I like its API with functional flavor, but somehow their JSON example is _atrociously_ slow (like, orders of magnitude, 250-500 times slower).

The [JSON sample][json-sample] being parsed is a typical JSON data, which has 923 lines. This translates to ~530k lines of JSON per second, and that is actually on par with some Rust parser combinator crates like [pom].

<!-- Links. -->

[json-bench]: ./src/json
[json-sample]: ./src/json/@sample.ts
[sigma]: https://github.com/norskeld/sigma
[parjs]: https://github.com/GregRos/parjs
[arcsecond]: https://github.com/francisrstokes/arcsecond
[pom]: https://github.com/J-F-Liu/pom
Loading

0 comments on commit fd39bb1

Please sign in to comment.