Created
February 3, 2016 08:47
-
-
Save adriang133/16da77ca307049ddca49 to your computer and use it in GitHub Desktop.
Performance test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LogicalExpression testCustomExp = CustomLogicalExpressionHelper.ParseXml(testP); | |
Expression exp = LogicalExpressionHelper.ParseXml(testP); | |
var expParams = LogicalExpressionHelper.GetParameters(exp); | |
LambdaExpression lambda = Expression.Lambda(exp, expParams.Keys); | |
Delegate d = lambda.Compile(); | |
string[] parameters = new string[] {"a", "b", "d", "e" }; | |
int numberOfTests = 100000; | |
Stopwatch sw = new Stopwatch(); | |
sw.Start(); | |
for (int i = 1; i <= numberOfTests; i++ ) | |
{ | |
bool tr = (bool)d.DynamicInvoke(expParams.Values.Cast<object>().ToArray()); | |
} | |
sw.Stop(); | |
Console.WriteLine("Standard: " + sw.ElapsedMilliseconds); | |
sw.Restart(); | |
for (int i = 1; i <= numberOfTests; i++) | |
{ | |
bool tr = testCustomExp.Evaluate(parameters); | |
} | |
sw.Stop(); | |
Console.WriteLine("Custom: " + sw.ElapsedMilliseconds); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment