Пример #1
0
        private static void TimeMethodCreationViaExpression(int Iterations)
        {
            var expressionTime = TimeSpan.Zero;

            for (var i = 0; i < Iterations; i++)
            {
                expressionTime += MethodCreation.CreateViaExpression().Item2;
            }

            Console.Out.WriteLine("Expression time: " + expressionTime.ToString());
        }
Пример #2
0
        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));
        }