Tests/UnitTestImpromptuInterface.Clay/ClayTest.cs
/// <summary>
/// Impromptu's Interface Proxy is about the same Speed as Clay's
/// </summary>
Impromptu's Interface Proxy is about the same Speed as Clay's
Impromptu ' s Interface Proxy is about the same Speed as Clay ' s
[Test]
        [Category("Performance")]
        public void SpeedTestInterface()
        {   
            dynamic New = new ClayFactory();
            IRobot tRobot = New.Robot().Name("Bender");
            IRobot tRobotI = Impromptu.ActLike<IRobot>(New.Robot().Name("Bender"));
             var tInteration = 50000;
             var tWatchC = TimeIt.Go(() =>
                                         {
                                             var tOut =
                                                 Impromptu.ActLike<IRobot>(New.Robot().Name("Bender"));
                                         }, tInteration);
            var tWatchC2 = TimeIt.Go(() =>
                                         {
                                             IRobot tOut = New.Robot().Name("Bender");
                                         },tInteration );
            TestContext.WriteLine("*CreateInterface*");
            TestContext.WriteLine("Impromptu: " + tWatchC.Elapsed);
            TestContext.WriteLine("Clay: " + tWatchC2.Elapsed);
            TestContext.WriteLine("Impromptu VS Clay: {0:0.0} x faster", (double)tWatchC2.ElapsedTicks / tWatchC.ElapsedTicks);
            Assert.Less(tWatchC.Elapsed, tWatchC2.Elapsed);
            var tWatch = TimeIt.Go(() => { var tOut = tRobotI.Name; }, tInteration);
            var tWatch2 = TimeIt.Go(() => { var tOut = tRobot.Name; }, tInteration);
            TestContext.WriteLine("*Get from Interface*");
            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Clay: " + tWatch2.Elapsed);
            TestContext.WriteLine("Impromptu VS Clay: {0:0.0} x faster", (double)tWatch2.ElapsedTicks / tWatch.ElapsedTicks);
             Assert.Less(tWatch.Elapsed, tWatch2.Elapsed);
        }
[ Test ] [ Category ( " " ) ] public void SpeedTestInterface ( ) { dynamic New = new ClayFactory ( ) ; IRobot tRobot = New . Robot ( ) . Name ( " " ) ; IRobot tRobotI = Impromptu . ActLike < IRobot > ( New . Robot ( ) . Name ( " " ) ) ; var tInteration = 50000 ; var tWatchC = TimeIt . Go ( ( ) => { var tOut = Impromptu . ActLike < IRobot > ( New . Robot ( ) . Name ( " " ) ) ; } , tInteration ) ; var tWatchC2 = TimeIt . Go ( ( ) => { IRobot tOut = New . Robot ( ) . Name ( " " ) ; } , tInteration ) ; TestContext . WriteLine ( " " ) ; TestContext . WriteLine ( " " + tWatchC . Elapsed ) ; TestContext . WriteLine ( " " + tWatchC2 . Elapsed ) ; TestContext . WriteLine ( " " , ( double ) tWatchC2 . ElapsedTicks / tWatchC . ElapsedTicks ) ; Assert . Less ( tWatchC . Elapsed , tWatchC2 . Elapsed ) ; var tWatch = TimeIt . Go ( ( ) => { var tOut = tRobotI . Name ; } , tInteration ) ; var tWatch2 = TimeIt . Go ( ( ) => { var tOut = tRobot . Name ; } , tInteration ) ; TestContext . WriteLine ( " " ) ; TestContext . WriteLine ( " " + tWatch . Elapsed ) ; TestContext . WriteLine ( " " + tWatch2 . Elapsed ) ; TestContext . WriteLine ( " " , ( double ) tWatch2 . ElapsedTicks / tWatch . ElapsedTicks ) ; Assert . Less ( tWatch . Elapsed , tWatch2 . Elapsed ) ; }
Impromptu's Interface Proxy is about the same Speed as Clay's
Impromptu ' s Interface Proxy is about the same Speed as Clay ' s