private static void TimeMethodCreationViaDynamicMethod(int Iterations) { var dynamicMethodTime = TimeSpan.Zero; for (var i = 0; i < Iterations; i++) { dynamicMethodTime += MethodCreation.CreateViaDynamicMethod().Item2; } Console.Out.WriteLine("DynamicMethod time: " + dynamicMethodTime.ToString()); }
private static void TestMethodCreation() { var expressionResult = MethodCreation.CreateViaExpression(); Console.Out.WriteLine("Expression result, f(4): " + expressionResult.Item1(4)); Console.Out.WriteLine("Expression result, f(5): " + expressionResult.Item1(5)); Console.Out.WriteLine("Expression result, f(6): " + expressionResult.Item1(6)); Console.Out.WriteLine(); var dynamicMethodResult = MethodCreation.CreateViaDynamicMethod(); Console.Out.WriteLine("DynamicMethod result, f(4): " + dynamicMethodResult.Item1(4)); Console.Out.WriteLine("DynamicMethod result, f(5): " + dynamicMethodResult.Item1(5)); Console.Out.WriteLine("DynamicMethod result, f(6): " + dynamicMethodResult.Item1(6)); }