-
I'm currently evaluating the usage of csly to replace an existing language parser. I use the "Simple Expression Evaluator" sample as a reference and benchmark the evaluation of The "old" library resides in C++ code, needs heavy
Any thoughts how performance could be improved? Admittedly, the expression is not a real world example, however I'd need to add some 250 keywords to the language to have a real comparison, so this was my first shot for an easy benchmark. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
Ah, for a fair comparison I'd need to remove the parser building from the benchmark code as this is probably done globally in the C++ DLL as well. However, parsing and evaluation are fair to compare. The full benchmark method looks line this:
This still gives a - albeit much more favorable - difference:
|
Beta Was this translation helpful? Give feedback.
-
If performance is a real concern for your use case I would recommend to go for ANTLR which is really performant (have tested it in my professional life). |
Beta Was this translation helpful? Give feedback.
-
Thanks for the frank reply. I also recognized quite many allocations, especially the generation of generic lists causes a lot of allocations. Maybe removing them wherever possible might help with performance, too (great session on the topic here). Will have to check if we change direction here or if performance is sufficient. Anyway, thanks for your help and keep up the great work here. |
Beta Was this translation helpful? Give feedback.
-
Hello @jbartlau a other axis for improvment is to use C# source generators as suggested by #466. It could bring perf improvment in 2 ways :
I Will start to really think about it. It is quite challenging as I want to keep backward compatibility and so will require an important rewrite of the CSLY internal APIs. |
Beta Was this translation helpful? Give feedback.
Hello, indeed I've found that this optim can be bad for some kind of parsers (notably json parser, see #435 ).
My benches yesterday were surely not sufficient. Thanks for reporting. Expression parsing is already quite well optimized. I think that C++ is there outperforming in term of CPU (no need for JIT), and memory consumption (no GC). Maybe memory consumption could be oprimized if had time for this 😊.
Maybe this performance issue is not that important on real world situation ? For now I can not help further, I real busy at work 😒.
Thanks for trying CSLY, it gives me improvement things to investigate.