Performance Testing

Sep 23, 2011 at 7:01 PM

I did a simple performance testing, measured time in 3 steps and got below result:

 

ExprParser ep = new ExprParser();

LambdaExpression lambda = ep.Parse("(int num1,num2) => 10-+num1+(+num2)"); // This step used 0.14 seconds by loop 2000 times

Delegate f = lambda.Compile(); // This step use 0.28 seconds by loop 2000 times

object res = f.DynamicInvoke( new object[ ] { 10, 20 } ); // This step use 0.01 seconds by loop 2000 times

 

The time to run expression only used 1/40 time of parsing and compiling the expression. For multiple used expression, cache the compiled delegate can significantly improve the performance.