public static void CheckSorting(IEnumerable <int> source, int n)
        {
            int count    = 0;
            int errCount = 0;

            PerformanceTimer.Time(() => {
                int prev = -1;
                foreach (int value in source)
                {
                    count++;
                    if (value < prev)
                    {
                        errCount++;
                    }
                    prev = value;
                }
            }, 1, "Iteraing items");

            if (count != n)
            {
                Console.WriteLine("Count mismatch: count={0}", count);
            }

            if (errCount == 0)
            {
                Console.WriteLine("Sorting OK");
            }
            else
            {
                Console.WriteLine("{0} Sorting ERRORS !!!", errCount);
                string values = "{" + String.Join(",", source) + "}";
                Console.WriteLine(values);
            }
        }
Example #2
0
        public void ImportFromMdbFileTest()
        {
            string path      = PathToTestFolder.Get(TestFolders.Db) + "Data\\";
            long   start     = 1009508;
            long   chunkSize = 10000;

            EidssUserContext.Init();
            DbManagerFactory.SetSqlFactory(bv.common.Configuration.Config.GetSetting("EidssConnectionString"));
            for (long i = start; i < 1009509; i += chunkSize)
            {
                var timer = new PerformanceTimer("mdb records loading", 0);
                using (var _manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
                {
                    var _accessor = Upload506Master.Accessor.Instance(null);
                    var _master   = _accessor.CreateNewT(_manager, null);
                    var result    = _master.GetItems(path + "Cddata.mdb", i, chunkSize);
                    timer.Stop();
                    Debug.WriteLine("records from {0} to {1} loading time:{2}", i, i + chunkSize, timer.Time());
                    timer = new PerformanceTimer("set item resolution", 0);
                    foreach (var item in _master.Items)
                    {
                        item.Resolution = (int)Upload506Resolution.Created;
                    }
                    timer.Stop();
                    Debug.WriteLine("set item resolution time:{0}", timer.Time());

                    Assert.AreEqual(Upload506FileError.Success, result);
                    Assert.AreEqual(chunkSize, _master.Items.Count);
                    Assert.AreEqual(Upload506MasterState.ReadyForValidation, _master.GetState());
                    timer = new PerformanceTimer("post", 0);
                    Assert.IsTrue(_accessor.Post(_manager, _master));
                    timer.Stop();
                    Debug.WriteLine("records from {0} to {1} posting time:{2}", i, i + chunkSize, timer.Time());
                }
            }
            EidssUserContext.Clear();
        }
Example #3
0
        public void LoadExcelFilePerformanceTest()
        {
            string path   = PathToTestFolder.Get(TestFolders.Db) + "Data\\";
            var    timer  = new PerformanceTimer("100 records loading", 0);
            var    result = master.GetItems(path + "506File100records.xlsx");

            timer.Stop();
            var t = timer.Time();

            Debug.WriteLine("100 records loading time: {0}", t);
            //Assert.IsTrue(t < 0.5, "100 record loading time is {0}", t);
            timer  = new PerformanceTimer("1000 records loading", 0);
            result = master.GetItems(path + "506File1000records.xlsx");
            timer.Stop();
            t = timer.Time();
            Debug.WriteLine("1000 records loading time: {0}", t);
            Assert.IsTrue(t < 1, "1000 record loading time is {0}", t);
            timer  = new PerformanceTimer("10000 records loading", 0);
            result = master.GetItems(path + "506File10000records.xlsx");
            timer.Stop();
            t = timer.Time();
            Debug.WriteLine("10000 records loading time: {0}", t);
            //Assert.IsTrue(t < 10, "1000 record loading time is {0}", t);

            timer  = new PerformanceTimer("20000 records loading", 0);
            result = master.GetItems(path + "506FileUploadExample.xlsx");
            timer.Stop();
            t = timer.Time();
            Debug.WriteLine("20000 records loading time: {0}", t);
            //Assert.IsTrue(t < 15, "20000 record loading time is {0}", t);
            timer = new PerformanceTimer("20000 records validation", 0);
            var validate = master.ValidateItems();

            Assert.IsFalse(validate);
            timer.Stop();
            t = timer.Time();
            Debug.WriteLine("20000 records validation time: {0}", t);
            //Assert.IsTrue(t < 10, "20000 record validation time is {0}", t);
            timer = new PerformanceTimer("20000 example records errors writing", 0);
            WriteErrorsToFile(path + "506FileUploadExampleErrors.xlsx");
            timer.Stop();
            t = timer.Time();
            Debug.WriteLine("20000 example records errors writing: {0}", t);

            timer  = new PerformanceTimer("100 example records loading", 0);
            result = master.GetItems(path + "506FileUploadExample100.xlsx");
            timer.Stop();
            t = timer.Time();
            Debug.WriteLine("100 example records loading time: {0}", t);
            //Assert.IsTrue(t < 5, "100 example record loading time is {0}", t);
            timer    = new PerformanceTimer("100 example records validation", 0);
            validate = master.ValidateItems();
            Assert.IsTrue(validate);
            timer.Stop();
            t = timer.Time();
            Debug.WriteLine("100 example records validation time: {0}", t);
            //Assert.IsTrue(t < 5, "100 example record validation time is {0}", t);
            timer = new PerformanceTimer("100 example records errors writing", 0);
            WriteErrorsToFile(path + "506FileUploadExample100Errors.xlsx");
            timer.Stop();
            t = timer.Time();
            Debug.WriteLine("100 example records errors writing: {0}", t);
        }