Prefer interpreted mode
dotnet provides a Compile(bool preferInterpretation) variant.
It is useful in scenarios where the expression is only used once.
This option could be present in the API for this package as an optional parameter without breaking changes.
Interesting. Do you know the difference in term of performance or memory consumption? Any other advantage or consideration?
cc @metoule @holdenmai
Interesting. Do you know the difference in term of performance or memory consumption? Any other advantage or consideration?
As with any perf question, only profiling the actual use case can give answers. However, one can expect that for expressions that are evaluated only once, the overhead of compilation might be larger than actually running an interpreter.
This comment (and thread) has other insights: https://github.com/dotnet/docs/issues/3866#issuecomment-349124653
Very interesting. Considering that DynamicExpresso expressions are usually quite simple, I'm not sure they benefit much from the JIT compiler. Also, I believe that most users rely on the Eval method that only executes the expression once.
I have to perform stronger benchmarks, but it has a nice impact on the unit tests execution time. Excluding the massive LiteralsTest.Non_Ascii_Chars, the execution time decreases by roughly 10 to 15%.
LiteralsTest.Non_Ascii_Chars goes from about 5s to about 1s.
To roll this out, I think we can set it to true for all calls to Eval, and offer the option for the other use cases. I'll see how we can revisit the Lambda public API to better reflect the intent.