Esempio n. 1
0
        public BranchingFactorGroupResult TestUnSequential(int branchFactor, int numInsertions)
        {
            var       result = new BranchingFactorGroupResult();
            Stopwatch timer  = new Stopwatch();

            timer.Start();
            var node = new BPTreeNode <int, int>();

            node.BranchingFactor = branchFactor;

            for (int i = 1; i < numInsertions + 1; i++)
            {
                timer.Stop();
                var num = GetRandomNumber(result.UsedNumbers);
                timer.Start();
                node = node.Insert(num, num);
            }

            timer.Stop();
            result.TestResult = timer.ElapsedTicks;
            //result.NodeResult = node;

            for (int i = 0; i < 5; i++)
            {
                var randomIndex  = GetRandomNumber(0, result.UsedNumbers.Keys.Count - 1, new Dictionary <int, int>());
                var randomNumber = result.UsedNumbers.Keys.ElementAt((int)randomIndex);
                timer.Restart();
                var queryResult = node.Query(randomNumber);
                timer.Stop();
                result.ReadResults.Add(timer.ElapsedTicks);
            }
            return(result);
        }
Esempio n. 2
0
        public BranchingFactorGroupResult TestSequential(int branchFactor, int numInsertions)
        {
            var       result = new BranchingFactorGroupResult();
            Stopwatch timer  = new Stopwatch();

            timer.Start();
            var node = new BPTreeNode <int, int>();

            node.BranchingFactor = branchFactor;

            for (int i = 1; i < numInsertions + 1; i++)
            {
                node = node.Insert(i, i);
            }

            timer.Stop();
            result.TestResult = timer.ElapsedTicks;
            //result.NodeResult = node;

            for (int i = 0; i < 5; i++)
            {
                var randomNumber = GetRandomNumber(1, numInsertions, new Dictionary <int, int>());
                timer.Restart();
                var queryResult = node.Query(randomNumber);
                timer.Stop();
                result.ReadResults.Add(timer.ElapsedTicks);
            }
            return(result);
        }