soasme / PeppaPEG

PEG Parser in ANSI C
https://soasme.com/PeppaPEG
MIT License
55 stars 7 forks source link

Performance Optimization: Replace errmsg with error struct. #122

Closed soasme closed 3 years ago

soasme commented 3 years ago

Given tables.go,

Before:

$ time ./cli ast --grammar-file ../tests/golang-v1.17.peg --grammar-entry SourceFile ../tables.go > /dev/null

real    0m4.781s
user    0m3.879s
sys 0m0.022s

After:

$ time ./cli ast --grammar-file ../tests/golang-v1.17.peg --grammar-entry SourceFile ../tables.go > /dev/null

real    0m1.253s
user    0m0.843s
sys 0m0.018s

Conclusion:

The change will cut down the execution time by 78%.