Esempio n. 1
0
        public void Execute_Modified_ShouldEqualOriginal()
        {
            var originalResults = new Dictionary <int, double>();

            void SaveToOriginalResultsDictionary(int totalRecords, double iqm)
            {
                originalResults.Add(totalRecords, iqm);
            }

            var modifiedResults = new Dictionary <int, double>();

            void SaveToModifiedResultsDictionary(int totalRecords, double iqm)
            {
                modifiedResults.Add(totalRecords, iqm);
            }

            var IQM = new IncrementalIQMManager(TestDataPath);

            IQM.Execute(SaveToOriginalResultsDictionary);
            IQM.Execute(SaveToModifiedResultsDictionary);

            Assert.AreEqual(originalResults.Count, modifiedResults.Count);
            foreach (var key in originalResults.Keys)
            {
                Assert.AreEqual(originalResults[key], modifiedResults[key]);
            }
        }
Esempio n. 2
0
        public void Execute_UsesPassedHandler()
        {
            var runs = 0;

            void IncrementRuns(int totalRecords, double iqm)
            {
                runs++;
            }

            var incrementingIQM = new IncrementalIQMManager(TestDataPath, IncrementRuns);

            incrementingIQM.Execute();

            Assert.AreEqual(runs, 17);
        }
Esempio n. 3
0
        private void TestRun(CalculationType calcType, InsertionType insertType, int runCount, StreamWriter sw)
        {
            sw.Write($"{calcType.ToString()},{insertType.ToString()},");
            var iqmm     = new IncrementalIQMManager(PerformanceTestInputFilePath, calcType, insertType);
            var runtimes = new List <double>();

            for (var i = 0; i < runCount; i++)
            {
                var runtime = iqmm.Execute();
                runtimes.Add(runtime);
                sw.Write($"{runtime},");
            }
            var avgRuntime = runtimes.Sum() / runtimes.Count;

            sw.WriteLine(avgRuntime);
        }
Esempio n. 4
0
        public void Execute_Standard_ShouldCalculateIQMCorrectly()
        {
            var resultsDict = new Dictionary <int, double>();

            void SaveToDictionary(int totalRecords, double iqm)
            {
                resultsDict.Add(totalRecords, iqm);
            }

            var standardIQM = new IncrementalIQMManager(TestDataPath, SaveToDictionary);

            standardIQM.Execute(CalculationType.Standard);

            Assert.AreEqual(resultsDict.Count, TestResults.StandardResults.Count);
            foreach (var key in resultsDict.Keys)
            {
                Assert.AreEqual(resultsDict[key], TestResults.StandardResults[key]);
            }
        }
Esempio n. 5
0
        public void Execute_InsertionMethod_ShouldNotAffectResults()
        {
            var insertInPlaceResults = new Dictionary <int, double>();

            void SaveInsertInPlaceResults(int totalRecords, double iqm)
            {
                insertInPlaceResults.Add(totalRecords, iqm);
            }

            var addAndSortResults = new Dictionary <int, double>();

            void SaveToAddAndSortResults(int totalRecords, double iqm)
            {
                addAndSortResults.Add(totalRecords, iqm);
            }

            var IQM = new IncrementalIQMManager();

            // should work with every calculation type

            // Original
            IQM.Execute(TestDataPath, CalculationType.Original, InsertionType.AddAndSort, SaveToAddAndSortResults);
            IQM.Execute(TestDataPath, CalculationType.Original, InsertionType.InsertInPlace, SaveInsertInPlaceResults);

            Assert.AreEqual(insertInPlaceResults.Count, addAndSortResults.Count);
            foreach (var key in insertInPlaceResults.Keys)
            {
                Assert.AreEqual(insertInPlaceResults[key], addAndSortResults[key]);
            }

            // Modified
            IQM.Execute(TestDataPath, CalculationType.Modified, InsertionType.AddAndSort, SaveToAddAndSortResults);
            IQM.Execute(TestDataPath, CalculationType.Modified, InsertionType.InsertInPlace, SaveInsertInPlaceResults);

            Assert.AreEqual(insertInPlaceResults.Count, addAndSortResults.Count);
            foreach (var key in insertInPlaceResults.Keys)
            {
                Assert.AreEqual(insertInPlaceResults[key], addAndSortResults[key]);
            }

            // Standard
            IQM.Execute(TestDataPath, CalculationType.Standard, InsertionType.AddAndSort, SaveToAddAndSortResults);
            IQM.Execute(TestDataPath, CalculationType.Standard, InsertionType.InsertInPlace, SaveInsertInPlaceResults);

            Assert.AreEqual(insertInPlaceResults.Count, addAndSortResults.Count);
            foreach (var key in insertInPlaceResults.Keys)
            {
                Assert.AreEqual(insertInPlaceResults[key], addAndSortResults[key]);
            }
        }