Skip to content

2.3.1 / FastExpressionCompiler

Compare
Choose a tag to compare
@AntonovAnton AntonovAnton released this 12 May 23:09
· 6 commits to main since this release
e406bcc

What's Changed

  • Added IExpressionCompiler interface, which allows you to inject your own compiler. This is useful if you want to use a different compiler or if you want to customize the compilation process in some way.
  • Released MathEvaluator.FastExpressionCompiler library is an extension of the MathEvaluator library that uses the FastExpressionCompiler library to provide performance improvements of up to 10-40x compared to the built-in .NET LambdaExpression.Compile() method.
  • Enhanced benchmarks to compare standard and fast expression compilation.
  • Added logo.
  • Updated documentation.
  • Added other minor improvements.

Example of using the MathEvaluator.FastExpressionCompiler, more details in documentation:

using MathEvaluation.Extensions;

// Compile a double expression
var compiled = "x * y + z".CompileFast(new { x = 0, y = 0, z = 0 });
double result = compiled(new { x = 5, y = 6, z = 7 }); // Result: 47

// Compile a decimal expression
var compiledDecimal = "x / y".CompileDecimalFast(new { x = 0m, y = 0m });
decimal decimalResult = compiledDecimal(new { x = 20m, y = 4m }); // Result: 5

// Compile a boolean expression
var compiledBoolean = "x > y".CompileBooleanFast(new { x = 0, y = 0 });
bool booleanResult = compiledBoolean(new { x = 2, y = 3 }); // Result: false

// Compile a complex expression
var compiledComplex = "x + y * i".CompileComplexFast(new { x = 0, y = 0 });
Complex complexResult = compiledComplex(new { x = 3, y = 4 }); // Result: 3 + 4i

Full Changelog: 2.3.0...2.3.1