public void FuncDirectCall()
        {
            var sample = new SampleClass();

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (int i = 0; i < Iterations; i++)
            {
                sample.GiveAValue(100, "hello");
            }
            stopwatch.Stop();

            Console.WriteLine("Iterations: {0}\tElapsed: {1}", Iterations, stopwatch.ElapsedMilliseconds);
        }
Esempio n. 2
0
        public void FuncDirectCall()
        {
            var sample = new SampleClass();

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            for (int i = 0; i < Iterations; i++)
            {
                sample.GiveAValue(100, "hello");
            }
            stopwatch.Stop();

            Console.WriteLine("Iterations: {0}\tElapsed: {1}", Iterations, stopwatch.ElapsedMilliseconds);
        }
        public void FuncUsingReflection()
        {
            var sample = new SampleClass();
            MethodInfo meth = typeof (SampleClass).GetMethod("GiveAValue");
            var p1 = new object[] {100, "hello"};

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (int i = 0; i < Iterations; i++)
            {
                meth.Invoke(sample, p1);
            }
            stopwatch.Stop();

            Console.WriteLine("Iterations: {0}\tElapsed: {1}", Iterations, stopwatch.ElapsedMilliseconds);
        }
Esempio n. 4
0
        public void FuncUsingReflection()
        {
            var        sample = new SampleClass();
            MethodInfo meth   = typeof(SampleClass).GetMethod("GiveAValue");
            var        p1     = new object[] { 100, "hello" };

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            for (int i = 0; i < Iterations; i++)
            {
                meth.Invoke(sample, p1);
            }
            stopwatch.Stop();

            Console.WriteLine("Iterations: {0}\tElapsed: {1}", Iterations, stopwatch.ElapsedMilliseconds);
        }
        public void FuncUsingExpression()
        {
            var sample = new SampleClass();
            MethodInfo meth = typeof (SampleClass).GetMethod("GiveAValue");
            var p1 = new object[] {100, "hello"};

            Func<object, object[], object> action = LambdaBuilder.CreateFunction(meth);

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (int i = 0; i < Iterations; i++)
            {
                action(sample, p1);
            }
            stopwatch.Stop();

            Console.WriteLine("Iterations: {0}\tElapsed: {1}", Iterations, stopwatch.ElapsedMilliseconds);
        }
Esempio n. 6
0
        public void FuncUsingExpression()
        {
            var        sample = new SampleClass();
            MethodInfo meth   = typeof(SampleClass).GetMethod("GiveAValue");
            var        p1     = new object[] { 100, "hello" };

            Func <object, object[], object> action = LambdaBuilder.CreateFunction(meth);

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            for (int i = 0; i < Iterations; i++)
            {
                action(sample, p1);
            }
            stopwatch.Stop();

            Console.WriteLine("Iterations: {0}\tElapsed: {1}", Iterations, stopwatch.ElapsedMilliseconds);
        }