Пример #1
0
        public void TestCacheableMethodPocoGetValuePassNullDoubleCallTimed()
        {
            var tValue = new OverloadingMethPoco();

            var tCachedInvoke = new CacheableInvocation(InvocationKind.InvokeMember, "Func", 1);
            var tInteration   = 500000;
            var tWatch        = TimeIt.Go(() =>
            {
                var tOut  = tCachedInvoke.Invoke(tValue, null);
                var tOut2 = tCachedInvoke.Invoke(tValue, 2);
            }, tInteration);

            var tMethodInfo  = tValue.GetType().GetMethod("Func", new Type[] { typeof(object) });
            var tMethodInfo2 = tValue.GetType().GetMethod("Func", new Type[] { typeof(int) });
            var tWatch2      = TimeIt.Go(() =>
            {
                var tOut  = tMethodInfo.Invoke(tValue, new object[] { null });
                var tOut2 = tMethodInfo2.Invoke(tValue, new object[] { 2 });
            }, tInteration);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Reflection: " + tWatch2.Elapsed);
            TestContext.WriteLine("Impromptu VS Reflection: {0:0.0} x faster", (double)tWatch2.Elapsed.Ticks / tWatch.Elapsed.Ticks);
            Assert.Less(tWatch.Elapsed, tWatch2.Elapsed);
        }
Пример #2
0
        public void CacheableMethodPocoGetValuePassNullDoubleCallTimed()
        {
            var tValue = new OverloadingMethPoco();

            var tCachedInvoke = new CacheableInvocation(InvocationKind.InvokeMember, "Func", 1);

            Timer.Action1 = (() =>
            {
                var tOut = tCachedInvoke.Invoke(tValue, null);
                var tOut2 = tCachedInvoke.Invoke(tValue, 2);
            });

            var tMethodInfo  = tValue.GetType().GetMethod("Func", new Type[] { typeof(object) });
            var tMethodInfo2 = tValue.GetType().GetMethod("Func", new Type[] { typeof(int) });

            Timer.Action2 = (() =>
            {
                var tOut = tMethodInfo.Invoke(tValue, new object[] { null });
                var tOut2 = tMethodInfo2.Invoke(tValue, new object[] { 2 });
            });

            var elapsed = Timer.Go();

            Console.WriteLine("Impromptu: " + elapsed.Item1);
            Console.WriteLine("Refelection: " + elapsed.Item2);
            Console.WriteLine("Impromptu VS Reflection: {0}", TimeIt.RelativeSpeed(elapsed));
            Assert.Less(elapsed.Item1, elapsed.Item2);
        }
Пример #3
0
        public void TestMethodPocoGetValuePassNullDoubleCallTimed()
        {
#if DEBUG
            Assert.Ignore("Visual Studio slows down dynamic too much in debug mode");
#endif
            var tValue = new OverloadingMethPoco();


            var tInteration = 500000;
            var tWatch      = TimeIt.Go(() => {
                var tOut  = Impromptu.InvokeMember(tValue, "Func", null);
                var tOut2 = Impromptu.InvokeMember(tValue, "Func", 2);
            }, tInteration);

            var tMethodInfo  = tValue.GetType().GetMethod("Func", new Type[] { typeof(object) });
            var tMethodInfo2 = tValue.GetType().GetMethod("Func", new Type[] { typeof(int) });
            var tWatch2      = TimeIt.Go(() =>
            {
                var tOut  = tMethodInfo.Invoke(tValue, new object[] { null });
                var tOut2 = tMethodInfo2.Invoke(tValue, new object[] { 2 });
            }, tInteration);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Reflection: " + tWatch2.Elapsed);
            TestContext.WriteLine("Impromptu VS Reflection: {0:0.0} x faster", (double)tWatch2.Elapsed.Ticks / tWatch.Elapsed.Ticks);
            Assert.Less(tWatch.Elapsed, tWatch2.Elapsed);
        }
Пример #4
0
        public void MethodPocoGetValuePassNullDoubleCallTimed()
        {
#if DEBUG
            Assert.Ignore("Visual Studio slows down dynamic too much in debug mode");
#endif
            var tValue = new OverloadingMethPoco();


            Timer.Action1 = (() => {
                var tOut = Dynamic.InvokeMember(tValue, "Func", null);
                var tOut2 = Dynamic.InvokeMember(tValue, "Func", 2);
            });

            var tMethodInfo  = tValue.GetType().GetMethod("Func", new Type[] { typeof(object) });
            var tMethodInfo2 = tValue.GetType().GetMethod("Func", new Type[] { typeof(int) });
            Timer.Action2 = (() =>
            {
                var tOut = tMethodInfo.Invoke(tValue, new object[] { null });
                var tOut2 = tMethodInfo2.Invoke(tValue, new object[] { 2 });
            });

            var elapsed = Timer.Go(3 * TimeIt.Million);

            Console.WriteLine("Impromptu: " + elapsed.Item1);
            Console.WriteLine("Refelection: " + elapsed.Item2);
            Console.WriteLine("Impromptu VS Reflection: {0}", TimeIt.RelativeSpeed(elapsed));
            Assert.Less(elapsed.Item1, elapsed.Item2);
        }
Пример #5
0
        public void MethodPocoGetValuePassNullTimed()
        {
            #if DEBUG
            Assert.Ignore("Visual Studio slows down dynamic too much in debug mode");
            #endif

            var tValue = new OverloadingMethPoco();

            Timer.Action1=(() => { var tOut = Dynamic.InvokeMember(tValue, "Func", null); });
            var tMethodInfo = tValue.GetType().GetMethod("Func", new Type[] { typeof(object)});
            Timer.Action2=(() =>
            {
                var tOut = tMethodInfo.Invoke(tValue, new object[] { null});
            });

             var elapsed = Timer.Go(3 * TimeIt.Million);

            Console.WriteLine("Impromptu: " + elapsed.Item1);
            Console.WriteLine("Refelection: " + elapsed.Item2);
            Console.WriteLine("Impromptu VS Reflection: {0}", TimeIt.RelativeSpeed(elapsed));
            Assert.Less(elapsed.Item1, elapsed.Item2);
        }
Пример #6
0
        public void CacheableMethodPocoGetValuePassNullDoubleCallTimed()
        {
            var tValue = new OverloadingMethPoco();

            var tCachedInvoke = new CacheableInvocation(InvocationKind.InvokeMember, "Func", 1);
            Timer.Action1=(() =>
            {
                var tOut = tCachedInvoke.Invoke(tValue, null);
                var tOut2 = tCachedInvoke.Invoke(tValue, 2);
            });

            var tMethodInfo = tValue.GetType().GetMethod("Func", new Type[] { typeof(object) });
            var tMethodInfo2 = tValue.GetType().GetMethod("Func", new Type[] { typeof(int) });
            Timer.Action2=(() =>
            {
                var tOut = tMethodInfo.Invoke(tValue, new object[] { null });
                var tOut2 = tMethodInfo2.Invoke(tValue, new object[] { 2 });
            });

            var elapsed = Timer.Go();

             Console.WriteLine("Impromptu: " + elapsed.Item1);
            Console.WriteLine("Refelection: " + elapsed.Item2);
            Console.WriteLine("Impromptu VS Reflection: {0}", TimeIt.RelativeSpeed(elapsed));
            Assert.Less(elapsed.Item1, elapsed.Item2);
        }
Пример #7
0
        public void TestCacheableMethodPocoGetValuePassNullDoubleCallTimed()
        {
            var tValue = new OverloadingMethPoco();

            var tCachedInvoke = new CacheableInvocation(InvocationKind.InvokeMember, "Func", 1);
            var tInteration = 500000;
            var tWatch = TimeIt.Go(() =>
            {
                var tOut = tCachedInvoke.Invoke(tValue, null);
                var tOut2 = tCachedInvoke.Invoke(tValue, 2);
            }, tInteration);

            var tMethodInfo = tValue.GetType().GetMethod("Func", new Type[] { typeof(object) });
            var tMethodInfo2 = tValue.GetType().GetMethod("Func", new Type[] { typeof(int) });
            var tWatch2 = TimeIt.Go(() =>
            {
                var tOut = tMethodInfo.Invoke(tValue, new object[] { null });
                var tOut2 = tMethodInfo2.Invoke(tValue, new object[] { 2 });
            }, tInteration);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Reflection: " + tWatch2.Elapsed);
            TestContext.WriteLine("Impromptu VS Reflection: {0:0.0} x faster", (double)tWatch2.Elapsed.Ticks / tWatch.Elapsed.Ticks);
            Assert.Less(tWatch.Elapsed, tWatch2.Elapsed);
        }
Пример #8
0
        public void TestMethodPocoGetValuePassNullDoubleCallTimed()
        {
#if DEBUG
            Assert.Ignore("Visual Studio slows down dynamic too much in debug mode");
#endif
            var tValue = new OverloadingMethPoco();


            var tInteration = 500000;
            var tWatch = TimeIt.Go(() => { 
                var tOut = Impromptu.InvokeMember(tValue, "Func", null); 
                var tOut2 = Impromptu.InvokeMember(tValue, "Func", 2); }, tInteration);

            var tMethodInfo = tValue.GetType().GetMethod("Func", new Type[] { typeof(object) });
            var tMethodInfo2 = tValue.GetType().GetMethod("Func", new Type[] { typeof(int) });
            var tWatch2 = TimeIt.Go(() =>
            {
                var tOut = tMethodInfo.Invoke(tValue, new object[] { null });
                var tOut2 = tMethodInfo2.Invoke(tValue, new object[] { 2 });
            }, tInteration);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Reflection: " + tWatch2.Elapsed);
            TestContext.WriteLine("Impromptu VS Reflection: {0:0.0} x faster", (double)tWatch2.Elapsed.Ticks / tWatch.Elapsed.Ticks);
            Assert.Less(tWatch.Elapsed, tWatch2.Elapsed);
        }