Benchmark №1. Initialization.
  • Creation of expression context object.
  • Importing methods from System.Math class.
  • Importing one custom type with one method.
bench1.png


Benchmark №2. Evaluate once.
  • Using the fastest way to evaluate "2+2" expression.
  • ILCalc's expression optimizer is turned off.
bench2.png


Benchmark №3. Evaluate many times.
  • Evaluating expression with the different parameter value.
  • Using no expression context re-creation (if it possible).
  • Using no re-parsing and recompiling (if it possible).
  • ILCalc's expression optimizer is turned off.
bench3.png


Benchmark №4. Parse & compile
  • Use expression context to parse and compile some expression.
  • Using no context re-creation.
  • Using FLEE Options.LiteralsAsInteger = true.
  • ILCalc's expression optimizer is turned off.
bench4.png


Benchmark №5. ILCalc optimizer.
  • Use Evaluator and Interpret objects to evaluate expression with unknown arguments.
bench5.png


Benchmark №6. Expression tabulation.
  • Evaluating expression with the parameter values from some range.
  • Using no expression context re-creation and no re-parsing and recompiling.
  • ILCalc's expression optimizer is turned off.
bench6.png


Conclusion
  • Performance benefit of ILCalc is the cost of many flexibility restrictions - you can't use different types in expression: can't work with dates, strings and other types.
  • If you need for only simple arithmetics in the expressions, ILCalc - is the best choose from tested .NET expression evaluators.
  • Using the different ILCalc's evaluation objects you may get the fastest way to evaluate expressions depending your personal usage scenario.
  • ILCalc's expression optimizer may provide extra performance benefit (much valuable when interpreter is used).
  • If you need more then simple arithmetics, you may see at FLEE and NCalc projects.

Other
  • Test results based on ILCalc version 0.9.5.1 build.
  • Benchmarks source code available in the project source code.
  • If you found some of this test invalid, please, contact me.

Last edited Sep 7, 2009 at 11:30 AM by Pelmen64, version 10

Comments

No comments yet.