williamthome / euneus

An incredibly flexible and performant JSON parser, generator and formatter in pure Erlang.
https://hex.pm/packages/euneus
Apache License 2.0
22 stars 2 forks source link

How do the benchmarks work? #1

Closed eproxus closed 9 months ago

eproxus commented 10 months ago

I'm interested in the benchmarks presented. It is a bit unclear to me what is actually compared.

How come Euneus is faster even though it in theory does more work than Thoas? Are the benchmarks including the new Euneus encoders or not?

williamthome commented 10 months ago

Hi, @eproxus! You are right, things are unclear at the moment. Improve documentation, add specs, and embed benchmarks are on the Euneus roadmap. I'm busy now, but I will open a PR to explain what you asked as soon as possible. Thanks for this issue!

williamthome commented 10 months ago

In a nutshell, organizing the Thoas code and inlining some functions have improved the performance. About the new encoders... yes, the new encoders option is implemented and considered in the benchmarks.

williamthome commented 10 months ago

I integrated benchmarks into the project.

About the optimization, rewriting Thoas allowed me to see some non-optimized code, and I believe there is more to optimize. As I said before, the optimization comes from code organization and inlining some functions. There is no magic here :) English is not my best, so docs may contain unclear things.

Feel free to test and bring suggestions/feedback o/

williamthome commented 10 months ago

In theory, Euneus does not do more work than Thoas. Compare Thoas vs Euneus implementation of the value encoding. Both are just calling a function.

williamthome commented 10 months ago

There are a lot of updates since my last comments. Please see the README file and let me know if you have any additional questions or suggestions :slightly_smiling_face: