private static void TestInDecreasingOrderBPlusTreeRW(int maxDegree) { Stopwatch sw = Stopwatch.StartNew(); { var bPlusTree = new BPlusTreeRW <long, Measurement>(maxDegree); Task task = null; for (int i = NUMBER_OF_INSERTION; i >= 1; i--) { bPlusTree.Insert(i, new Measurement()); if (i == NUMBER_OF_INSERTION) { task = Task.Factory.StartNew(() => { long res = 0; for (int k = NUMBER_OF_INSERTION; k >= 1; k--) { Measurement value; bPlusTree.TryFindExact(k, out value); res += value.Id; } Console.WriteLine("Result: {0}", res); }); } } task.Wait(); sw.Stop(); Console.WriteLine("BPlusTreeRW: "); Console.WriteLine("Decreasing order. Insert {0} elements: {1} ms", NUMBER_OF_INSERTION, sw.ElapsedMilliseconds); } }
private static long TestInDecreasingOrder(int maxDegree) { long memBefore = GC.GetTotalMemory(false); Stopwatch sw = Stopwatch.StartNew(); { BPlusTree <long, Measurement> bPlusTree = new BPlusTree <long, Measurement>(maxDegree); for (int i = NUMBER_OF_INSERTION; i >= 1; i--) { bPlusTree.Insert(i, new Measurement()); } sw.Stop(); long memAfter = GC.GetTotalMemory(false); Console.WriteLine("BPlusTree: "); Console.WriteLine("Decreasing order. Insert {0} elements: {1} ms", NUMBER_OF_INSERTION, sw.ElapsedMilliseconds); Console.WriteLine("Memory: {0} MBytes", (memAfter - memBefore) / 1024 / 1024); Console.WriteLine("Height: {0} ", bPlusTree.GetHeight()); HashSet <long> allWrittenNumbers = new HashSet <long>(); for (int i = NUMBER_OF_INSERTION; i >= 1; i--) { allWrittenNumbers.Add(i); } CheckCorrectness(bPlusTree, allWrittenNumbers); } sw = Stopwatch.StartNew(); { var bPlusTree = new BPlusTreeRW <long, Measurement>(maxDegree); List <Task> tasks = new List <Task>(); for (int i = NUMBER_OF_INSERTION; i >= 1; i--) { bPlusTree.Insert(i, new Measurement()); if (i == NUMBER_OF_INSERTION) { tasks.Add(Task.Factory.StartNew(() => { long res = 0; for (int k = NUMBER_OF_INSERTION; k >= 1; k--) { Measurement value; bPlusTree.TryFindExact(k, out value); res += value.Id; } Console.WriteLine("Result: {0}", res); })); tasks.Add(Task.Factory.StartNew(() => { long res = 0; for (int k = NUMBER_OF_INSERTION; k >= 1; k--) { Measurement value; bPlusTree.TryFindExact(k, out value); res += value.Id; } Console.WriteLine("Result: {0}", res); })); tasks.Add(Task.Factory.StartNew(() => { long res = 0; for (int k = NUMBER_OF_INSERTION; k >= 1; k--) { Measurement value; bPlusTree.TryFindExact(k, out value); res += value.Id; } Console.WriteLine("Result: {0}", res); })); } } Task.WaitAll(tasks.ToArray()); sw.Stop(); long memAfter = GC.GetTotalMemory(false); Console.WriteLine("BPlusTreeRW: "); Console.WriteLine("Decreasing order. Insert {0} elements: {1} ms", NUMBER_OF_INSERTION, sw.ElapsedMilliseconds); Console.WriteLine("Memory: {0} MBytes", (memAfter - memBefore) / 1024 / 1024); Console.WriteLine("Height: {0} ", bPlusTree.GetHeight()); } return(sw.ElapsedMilliseconds); }