Example #1
0
        public void PerfTest()
        {
            var type        = typeof(TestView);
            var defFactory  = new DefaultViewActivator();
            var fastFactory = new FastViewActivator();

            var activator     = defFactory.Register(type);
            var fastActivator = fastFactory.Register(type);
            var iterations    = 1000000;

            Stopwatch sw = new Stopwatch();

            sw.Start();

            for (int i = 0; i < iterations; i++)
            {
                var view = activator.Activate(type);
            }
            sw.Stop();

            Console.WriteLine("Default took: {0}ms", sw.Elapsed.TotalMilliseconds);
            sw.Reset();

            sw.Start();

            for (int i = 0; i < iterations; i++)
            {
                var view = fastActivator.Activate(type);
            }
            sw.Stop();
            Console.WriteLine("Fast took: {0}ms", sw.Elapsed.TotalMilliseconds);
        }
Example #2
0
 public void FastCreateViewInstance()
 {
     var type = typeof(TestView);
     var factory = new FastViewActivator();
     var activator = factory.Register(type);
     var view = activator.Activate(type);
     Assert.IsNotNull(view);
     Assert.IsAssignableFrom(typeof(TestView), view);
 }
Example #3
0
        public void FastCreateViewInstance()
        {
            var type      = typeof(TestView);
            var factory   = new FastViewActivator();
            var activator = factory.Register(type);
            var view      = activator.Activate(type);

            Assert.IsNotNull(view);
            Assert.IsAssignableFrom(typeof(TestView), view);
        }
Example #4
0
        public void PerfTest()
        {
            var type = typeof(TestView);
            var defFactory = new DefaultViewActivator();
            var fastFactory = new FastViewActivator();

            var activator = defFactory.Register(type);
            var fastActivator = fastFactory.Register(type);
            var iterations = 1000000;

            Stopwatch sw = new Stopwatch();
            sw.Start();

            for (int i = 0; i < iterations; i++)
            {
                var view = activator.Activate(type);
            }
            sw.Stop();

            Console.WriteLine("Default took: {0}ms", sw.Elapsed.TotalMilliseconds);
            sw.Reset();

            sw.Start();

            for (int i = 0; i < iterations; i++)
            {
                var view = fastActivator.Activate(type);
            }
            sw.Stop();
            Console.WriteLine("Fast took: {0}ms", sw.Elapsed.TotalMilliseconds);
        }