Exemple #1
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);
        }
Exemple #2
0
        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);
        }
Exemple #3
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);
        }
        public void TestSetTimed()
        {
            // Compares PB duck-typing with plain reflection and ImpromptuInterfaces (InvokeSet and using an ActLike<> invocation)
            // So far, PB-duck-typing is about twice as slow (when profiled) as II. Perhaps this can get better... Though the penalty
            // may be worth it when considering the extra features (like fuzzy-ducking)
            var tPoco = new PropPoco();

            var tSetValue = "1";

            var tWatch = TimeIt.Go(() =>
            {
                Impromptu.InvokeSet(tPoco, "Prop1", tSetValue);
            }, 500000);
            var tPropertyInfo = tPoco.GetType().GetProperty("Prop1");
            var tWatch2       = TimeIt.Go(() => tPropertyInfo.SetValue(tPoco, tSetValue, new object[] {}), TIMES);
            var ducked        = tPoco.DuckAs <IPropPoco>();

            Assert.IsNotNull(ducked);
            var tWatch3 = TimeIt.Go(() => ducked.Prop1 = tSetValue, TIMES);


            TestContext.WriteLine("InvokeSet: " + tWatch.Elapsed);
            TestContext.WriteLine("Reflection: " + tWatch2.Elapsed);
            TestContext.WriteLine("Ducked: " + tWatch3.Elapsed);
        }
Exemple #5
0
        static void Main(string[] args)
        {
            var custTimer     = new TimeIt();
            var executionTime = new TimeSpan();

            //This overload lets you pass a params array
            executionTime = custTimer.Start(GenerateNumbers, 1, 2, 3, 4, 5);

            //Use an anonymous function
            executionTime = custTimer.Start(() =>
            {
                //timer will stop at the end of this block of code
            });

            //Wrap your code within an Using statement
            using (var byUsing = new TimeIt())
            {
                GenerateNumbers();
                //Before end using, retrieve elapsed time from object
                executionTime = byUsing.ElapsedTime;
            }

            //Use it with lambda expressions (lambda will return execution Time)  by using Invoke Method()
            using (TimeIt.Invoke(ts => Console.Write("Method exec time: " + ts.Milliseconds)))
                GenerateNumbers();


            //Pass to Invoke the function that will receive the TimeSpan before intern object disposal
            using (TimeIt.Invoke(ProcessResult))
                GenerateNumbers();
            //Keep the console open
            Console.ReadKey();
        }
Exemple #6
0
 protected List <RootEntry> LoadRootEntries(IConfig config, TimeIt timeIt)
 {
     if (_loadCatalogService != null)
     {
         return(_loadCatalogService.LoadRootEntries(config, timeIt));
     }
     return(null);
 }
Exemple #7
0
 private void LogTimeIt(TimeIt timeIt)
 {
     if (timeIt != null)
     {
         foreach (var labelElapsed in timeIt.ElapsedList)
         {
             _clientForm.Addline("Loaded {0} in {1} msec", labelElapsed.Label, labelElapsed.ElapsedMsec);
         }
         _clientForm.Addline("Total Load time for {0} files in {1} msec", timeIt.ElapsedList.Count(), timeIt.TotalMsec);
     }
 }
Exemple #8
0
        public void TestFastDynamicInvokeAction()
        {
            Action <int> tFunc       = it => it.ToString();
            var          tStopWatch1 = TimeIt.Go(() => tFunc.FastDynamicInvoke(5));

            var tStopWatch2 = TimeIt.Go(() => tFunc.DynamicInvoke(5));

            TestContext.WriteLine("Impromptu: " + tStopWatch1.Elapsed);
            TestContext.WriteLine("Reflection: " + tStopWatch2.Elapsed);
            TestContext.WriteLine("Impromptu VS Reflection: {0:0.0} x faster", (double)tStopWatch2.Elapsed.Ticks / tStopWatch1.Elapsed.Ticks);
            Assert.Less(tStopWatch1.Elapsed, tStopWatch2.Elapsed);
        }
Exemple #9
0
        public void TestConstructorTimed()
        {
            var tWatch  = TimeIt.Go(() => { var tOut = Impromptu.InvokeConstructor(typeof(Tuple <string>), "Test"); });
            var tWatch2 = TimeIt.Go(() =>
            {
                var tOut = Activator.CreateInstance(typeof(Tuple <string>), "Test");
            });

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Refelection: " + 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);
        }
        public void TestConstructorValueTypeTimed()
        {
            var tIter = 1000000;

            var tWatch  = TimeIt.Go(() => { var tOut = Dynamic.InvokeConstructor(typeof(DateTime), 2010, 1, 20); }, tIter);
            var tWatch2 = TimeIt.Go(() =>
            {
                var tOut = Activator.CreateInstance(typeof(DateTime), 2010, 1, 20);
            }, tIter);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Refelection: " + 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);
        }
Exemple #11
0
        public void TestCacheableSetNullTimed()
        {
            var tPoco = new PropPoco();

            String tSetValue     = null;
            var    tCachedInvoke = new CacheableInvocation(InvocationKind.Set, "Prop1");
            var    tWatch        = TimeIt.Go(() => tCachedInvoke.Invoke(tPoco, tSetValue), 500000);
            var    tPropertyInfo = tPoco.GetType().GetProperty("Prop1");
            var    tWatch2       = TimeIt.Go(() => tPropertyInfo.SetValue(tPoco, tSetValue, new object[] { }), 500000);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Refelection: " + 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);
        }
Exemple #12
0
        public LoaderForm(IConfig config, IEnumerable <string> cdeList, TimeIt timeIt)
        {
            InitializeComponent();
            _config  = config;
            _cdeList = cdeList;
            _timeIt  = timeIt;

            // Set to top left of application if it is available.
            _config.RestoreConfigFormTopLeft(this);

            AutoWaitCursor.Cursor           = Cursors.WaitCursor;
            AutoWaitCursor.Delay            = new TimeSpan(0, 0, 0, 0, 25);
            AutoWaitCursor.MainWindowHandle = Handle;
            AutoWaitCursor.Start();
        }
Exemple #13
0
        public void TestCachedConstructorValueTypeTimed()
        {
            var tIter         = 1000000;
            var tCachedInvoke = new CacheableInvocation(InvocationKind.Constructor, argCount: 3);
            var tWatch        = TimeIt.Go(() => { var tOut = tCachedInvoke.Invoke(typeof(DateTime), 2010, 1, 20); }, tIter);
            var tWatch2       = TimeIt.Go(() =>
            {
                var tOut = Activator.CreateInstance(typeof(DateTime), 2010, 1, 20);
            }, tIter);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Refelection: " + 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);
        }
Exemple #14
0
        public void TestCacheableMethodPocoVoidTimed()
        {
            var tValue = new Dictionary <object, object>();

            var tCachedInvoke = new CacheableInvocation(InvocationKind.InvokeMemberAction, "Clear");

            var tWatch      = TimeIt.Go(() => tCachedInvoke.Invoke(tValue));
            var tMethodInfo = tValue.GetType().GetMethod("Clear", new Type[] { });
            var tWatch2     = TimeIt.Go(() => tMethodInfo.Invoke(tValue, new object[] { }));

            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);
        }
Exemple #15
0
        public void TestGetStaticTimed()
        {
            var tStaticType = typeof(DateTime);
            var tTarget     = tStaticType.WithStaticContext();
            var tWatch      = TimeIt.Go(() => { var tOut = Impromptu.InvokeGet(tTarget, "Today"); }, 500000);
            var tMethodInfo = typeof(DateTime).GetProperty("Today").GetGetMethod();
            var tWatch2     = TimeIt.Go(() =>
            {
                var tOut = tMethodInfo.Invoke(tStaticType, new object[] { });
            }, 500000);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Refelection: " + 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);
        }
Exemple #16
0
        public void SpeedTestPrototype()
        {
            dynamic NewI = Builder.New();
            dynamic NewE = Builder.New <ExpandoObject>();
            dynamic NewP = Builder.New <Robot>();
            dynamic NewC = new ClayFactory();

            var   tRobotI = NewI.Robot(Name: "Bender");
            var   tRobotC = NewC.Robot(Name: "Bender");
            var   tRobotE = NewE.Robot(Name: "Bender");
            Robot tRobotP = NewP.Robot(Name: "Bender");

            var tWatchI = TimeIt.Go(() =>
            {
                var tOut = tRobotI.Name;
            });

            var tWatchC = TimeIt.Go(() =>
            {
                var tOut = tRobotC.Name;
            });

            var tWatchE = TimeIt.Go(() =>
            {
                var tOut = tRobotE.Name;
            });

            var tWatchP = TimeIt.Go(() =>
            {
                var tOut = tRobotP.Name;
            });

            TestContext.WriteLine("Impromptu: " + tWatchI.Elapsed);
            TestContext.WriteLine("Clay: " + tWatchC.Elapsed);
            TestContext.WriteLine("Expando: " + tWatchE.Elapsed);
            TestContext.WriteLine("POCO: " + tWatchP.Elapsed);

            Assert.Less(tWatchI.Elapsed, tWatchC.Elapsed);

            TestContext.WriteLine("Impromptu VS Clay: {0:0.0} x faster", (double)tWatchC.ElapsedTicks / tWatchI.ElapsedTicks);
            TestContext.WriteLine("Expando  VS Clay:{0:0.0}  x faster", (double)tWatchC.ElapsedTicks / tWatchE.ElapsedTicks);
            TestContext.WriteLine("POCO  VS Clay:{0:0.0}  x faster", (double)tWatchC.ElapsedTicks / tWatchP.ElapsedTicks);
            TestContext.WriteLine("POCO  VS Impromptu:{0:0.0}  x faster", (double)tWatchI.ElapsedTicks / tWatchP.ElapsedTicks);
            TestContext.WriteLine("POCO  VS Expando:{0:0.0}  x faster", (double)tWatchE.ElapsedTicks / tWatchP.ElapsedTicks);
            TestContext.WriteLine("Expando  VS Impromptu:{0:0.0}  x faster", (double)tWatchI.ElapsedTicks / tWatchE.ElapsedTicks);
        }
Exemple #17
0
        public void TestMethodStaticMethodValueTimed()
        {
            var    tStaticType = typeof(DateTime);
            var    tTarget     = tStaticType.WithStaticContext();
            string tDate       = "01/20/2009";
            var    tWatch      = TimeIt.Go(() => { var tOut = Impromptu.InvokeMember(tTarget, "Parse", tDate); }, 500000);
            var    tMethodInfo = typeof(DateTime).GetMethod("Parse", new[] { typeof(string) });
            var    tWatch2     = TimeIt.Go(() =>
            {
                var tOut = tMethodInfo.Invoke(tStaticType, new object[] { tDate });
            }, 500000);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Refelection: " + 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);
        }
Exemple #18
0
        public List <RootEntry> LoadRootEntries(IConfig config, TimeIt timeIt)
        {
            List <RootEntry> rootEntries;
            var cachePathList = new[] { ".", config.ConfigPath };
            var loaderForm    = new LoaderForm(config, cachePathList, timeIt);

            try
            {
                loaderForm.ShowDialog();
            }
            finally
            {
                rootEntries = loaderForm.RootEntries;
                loaderForm.Dispose();
            }
            return(rootEntries);
        }
Exemple #19
0
        public void TestSetTimed()
        {
            var tPoco = new PropPoco();

            var tSetValue = "1";

            var tWatch        = TimeIt.Go(() => Impromptu.InvokeSet(tPoco, "Prop1", tSetValue), 500000);
            var tPropertyInfo = tPoco.GetType().GetProperty("Prop1");
            var tWatch2       = TimeIt.Go(() => tPropertyInfo.SetValue(tPoco, tSetValue, new object[] { }), 500000);



            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Refelection: " + 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);
        }
Exemple #20
0
        public void TestMethodPocoGetValue4argsTimed()
        {
            var tValue = "test 123 45 string";



            var tWatch      = TimeIt.Go(() => { var tOut = Impromptu.InvokeMember(tValue, "IndexOf", "45", 0, 14, StringComparison.InvariantCulture); }, 500000);
            var tMethodInfo = tValue.GetType().GetMethod("IndexOf", new Type[] { typeof(string), typeof(int), typeof(int), typeof(StringComparison) });
            var tWatch2     = TimeIt.Go(() =>
            {
                var tOut = tMethodInfo.Invoke(tValue, new object[] { "45", 0, 14, StringComparison.InvariantCulture });
            }, 500000);

            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);
        }
Exemple #21
0
        public void TestCacheableMethodPocoGetValueTimed()
        {
            var tValue = 1;


            var tCachedInvoke = new CacheableInvocation(InvocationKind.InvokeMember, "ToString");
            var tWatch        = TimeIt.Go(() => { var tOut = tCachedInvoke.Invoke(tValue); }, 500000);
            var tMethodInfo   = tValue.GetType().GetMethod("ToString", new Type[] { });
            var tWatch2       = TimeIt.Go(() =>
            {
                var tOut = tMethodInfo.Invoke(tValue, new object[] { });
            }, 500000);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Refelection: " + 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);
        }
Exemple #22
0
        public void TestConstructorNoARgTimed()
        {
            var tWatch  = TimeIt.Go(() => { var tOut = Impromptu.InvokeConstructor(typeof(List <string>)); });
            var tWatch2 = TimeIt.Go(() =>
            {
                var tOut = Activator.CreateInstance(typeof(List <string>));
            });
            var tWatch3 = TimeIt.Go(() =>
            {
                var tOut = Activator.CreateInstance <List <string> >();
            });

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

            Assert.Ignore("I don't think this is beatable at the moment");
            Assert.Less(tWatch.Elapsed, tWatch2.Elapsed);
        }
Exemple #23
0
        public void TestPropPocoGetValueTimed()
        {
            var tSetValue = "1";
            var tAnon     = new { Test = tSetValue };



            var tWatch = TimeIt.Go(() => { var tOut = Impromptu.InvokeGet(tAnon, "Test"); }, 500000);

            var tPropertyInfo = tAnon.GetType().GetProperty("Test");
            var tWatch2       = TimeIt.Go(() =>
            {
                var tOut = tPropertyInfo.GetValue(tAnon, null);
            }, 500000);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Refelection: " + 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);
        }
        public void TestCacheableMethodStaticMethodValueTimed()
        {
            var    tStaticType = typeof(DateTime);
            var    tContext    = new StaticContext(tStaticType);
            string tDate       = "01/20/2009";

            var tCachedInvoke = new CacheableInvocation(InvocationKind.InvokeMember, "Parse", argCount: 1,
                                                        context: tContext);
            var tWatch      = TimeIt.Go(() => { var tOut = tCachedInvoke.Invoke(tStaticType, tDate); }, 500000);
            var tMethodInfo = typeof(DateTime).GetMethod("Parse", new[] { typeof(string) });
            var tWatch2     = TimeIt.Go(() =>
            {
                var tOut = tMethodInfo.Invoke(tStaticType, new object[] { tDate });
            }, 500000);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Refelection: " + 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);
        }
        public void TestCacheableGetStaticTimed()
        {
            var tStaticType   = typeof(DateTime);
            var tContext      = new StaticContext(tStaticType);
            var tCachedInvoke = new CacheableInvocation(InvocationKind.Get, "Today", context: tContext);

            var tWatch = TimeIt.Go(() =>
            {
                var tOut = tCachedInvoke.Invoke(tStaticType);
            }, 500000);
            var tMethodInfo = typeof(DateTime).GetProperty("Today").GetGetMethod();

            var tWatch2 = TimeIt.Go(() =>
            {
                var tOut = tMethodInfo.Invoke(tStaticType, new object[] { });
            }, 500000);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Refelection: " + 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);
        }
Exemple #26
0
        public void TestCacheableGetValueTimed()
        {
            var tSetValue = "1";
            var tAnon     = new PropPoco()
            {
                Prop1 = tSetValue
            };


            var tInvoke = new CacheableInvocation(InvocationKind.Get, "Prop1");
            var tWatch  = TimeIt.Go(() => { var tOut = tInvoke.Invoke(tAnon); }, 500000);

            var tPropertyInfo = tAnon.GetType().GetProperty("Prop1");
            var tWatch2       = TimeIt.Go(() =>
            {
                var tOut = tPropertyInfo.GetValue(tAnon, null);
            }, 500000);

            TestContext.WriteLine("Impromptu: " + tWatch.Elapsed);
            TestContext.WriteLine("Refelection: " + 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);
        }
Exemple #27
0
        public CDEWinFormPresenter(
            ICDEWinForm form,
            IConfig config,
            ILoadCatalogService loadCatalogService = null)
            : base(form)
        {
            var timeIt = new TimeIt();

            _clientForm         = form;
            _config             = config;
            _loadCatalogService = loadCatalogService;
            _rootEntries        = LoadRootEntries(config, timeIt);

            _searchVals    = new string[_config.DefaultSearchResultColumnCount];
            _directoryVals = new string[_config.DefaultDirectoryColumnCount];
            _catalogVals   = new string[_config.DefaultCatalogColumnCount];

            SetSearchButton(true);
            RegisterListViewSorters();
            SetCatalogListView();

            InitialiseLog(timeIt);
        }
Exemple #28
0
        public void ReloadCatalogs()
        {
            // clear all current list views and tree views.
            var catalogHelper = _clientForm.CatalogListViewHelper;

            catalogHelper.SetList(null);
            var searchResultHelper = _clientForm.SearchResultListViewHelper;

            searchResultHelper.SetList(null);
            var directoryListHelper = _clientForm.DirectoryListViewHelper;

            directoryListHelper.SetList(null);

            var previousRootEntries = _rootEntries;

            foreach (var rootEntry in previousRootEntries)
            {
                rootEntry.ClearCommonEntryFields();
            }

            var timeIt         = new TimeIt();
            var newRootEntries = LoadRootEntries(_config, timeIt);

            _rootEntries = newRootEntries;
            if (_rootEntries.Count > 1)
            {   // this resets the tree view and directory list view
                SetNewDirectoryRoot(_rootEntries.First());
            }

            // set root entries.
            SetCatalogListView();

            _clientForm.Addline(string.Empty);
            _clientForm.Addline("{0} v{1} reloading catalogs", _config.ProductName, _config.Version);
            LogTimeIt(timeIt);
        }
Exemple #29
0
 private void InitialiseLog(TimeIt timeIt)
 {
     _clientForm.Addline("{0} v{1}", _config.ProductName, _config.Version);
     LogTimeIt(timeIt);
 }
Exemple #30
0
 public DataStore()
 {
     _reportedLoadMetric = false;
     _loadMetric         = new TimeIt();
 }