J-F-Liu / pom

PEG parser combinators using operator overloading without macros.
MIT License
496 stars 30 forks source link

Benchmark numbers in the README are not correct #11

Closed Marwes closed 7 years ago

Marwes commented 7 years ago

I got curious about the impressive speeds of pom's json example so I decided to measure it compared to my own json example. SinceRather surprisingly pom was several times faster than my own parser which is entirely statically dispatched. However when I looked through the benchmark source I realized that the benchmark forgets to reset the input before each iteration which meant that the parser only parsed the file on the first iteration, all other iterations only parsed an empty string.

let mut input = DataInput::new(&data);
b.iter(|| json::json().parse(&mut input).ok());

vs

b.iter(|| {
    let mut input = DataInput::new(&data);
    json::json().parse(&mut input).ok()
});

I see you have removed the benchmarks now so I am unsure what you want to do but you should probably at least update the performance numbers in the readme.

J-F-Liu commented 7 years ago

Thanks for pointing out, updated.