Comparing parsing of a list containing 12345678910
of sizes 1000, 2000 and 4000.
- Rust with Nom package commit here
- Haskell with Flatparse package commit here
Compares walking a string building no structures ("check") and parsing into a vector ("parse").
The Haskell version just builds a linked list and then converts that to an unboxed vector. I'm not sure what the Nom package does.
The parsers are slightly different - but there isn't a 2x difference between the two for a representative grammar, indicating the libraries are of equivalent performance.
You could sit and optimize both down, but the difference compared to attoparsec is already 10x.
My laptop:
vendor_id : GenuineIntel
cpu family : 6
model : 158
model name : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
stepping : 9
microcode : 0x8e
cpu MHz : 1899.979
cache size : 8192 KB
The Haskell benchmarks are actually disturbing because they're not O(n); i.e, Haskell is very mildly exponential, implying that Rust pulls ahead starting around n = 30,000. Any idea what's going on?