mna / pigeon

Command pigeon generates parsers in Go from a PEG grammar.
BSD 3-Clause "New" or "Revised" License
822 stars 66 forks source link

Tricks for >5x performance increase #151

Open fy0 opened 2 months ago

fy0 commented 2 months ago

These tricks based on tests of parser generated by pointlander/peg and pigeon with same grammer on my computer (12600kf, win11). baseline is pointlander/peg(~0.3s). First version of pigeon with same grammar took 4.5s.

Finally, we can got a parser cost 2x times by a parser generated by pointlander/peg. My current version take 0.5s to pass test, it's a huge boost compare to original version(4.5s), but still much slower than pointlander/peg. It's a ok trade off for me, because code generated by pigeon is more simple and clear. And easy to port builder to other languages.

If anyone know how to make it faster, please tell me.