protected void CompareSearch(List <MockItem> list, OptimizedCollection <MockItem> collection) { int key = new Random(new Random().Next(0, list.Count - 1)).Next(0, list.Count - 1); Watch.Reset(); var query = collection.Using <UniqueKeyQuery <MockItem, int> >(); Watch.Start(); var mockedInCollection = query.Get(key); Watch.Stop(); var elapsed4Collection = Watch.Elapsed; Watch.Reset(); Watch.Start(); var mockedInList = list.BinarySearch(new MockItem { Index = key }); Watch.Stop(); var elapsed4List = Watch.Elapsed; Console.WriteLine("For the list<T>, took {0} to get one item, \n FastLane took {1}.", elapsed4List, elapsed4Collection); }
protected void CompareSearch(List <MockItem> list, OptimizedCollection <MockItem> collection) { var max = list.Count; Watch.Reset(); var query = collection.Using <UniqueKeyQuery <MockItem, int> >(); Watch.Start(); for (int i = 0; i < max; i++) { var mockedInCollection = query.Get(i); } Watch.Stop(); var elapsed4Collection = Watch.Elapsed; Watch.Reset(); Watch.Start(); for (int i = 0; i < max; i++) { var mockedInList = list.BinarySearch(new MockItem { Index = i }); } Watch.Stop(); var elapsed4List = Watch.Elapsed; //Watch.Reset(); //Watch.Start(); //for (int i = 0; i < max; i++) //{ // var mockedInList = list.FirstOrDefault(item => item.Index == i); //} //Watch.Stop(); var elapsed4ListLinq = Watch.Elapsed; Console.WriteLine("For the list<T>, took {0} to get all items, for FastLane took {1}.", elapsed4List, elapsed4Collection); //Console.WriteLine("For the list<T> with linq, took {0} to get all items, for FastLane took {1}.", // elapsed4ListLinq, elapsed4Collection); }
protected void CompareSearch(List <MockItem> list, OptimizedCollection <MockItem> collection) { var max = list.Count; Watch.Reset(); var query = collection.Using <_Query>(); Watch.Start(); for (int i = 0; i < max; i++) { var mockedInCollection = query.Get(BitConverter.GetBytes(i)); } Watch.Stop(); var elapsed4Collection = Watch.Elapsed; Watch.Reset(); Watch.Start(); for (int i = 0; i < max; i++) { var mockedInList = list.BinarySearch(new MockItem { Index = i }); } Watch.Stop(); var elapsed4List = Watch.Elapsed; Watch.Reset(); Watch.Start(); for (int i = 0; i < max; i++) { var mockedInList = list.First(item => item.Index == i); } Watch.Stop(); var elapsed4ListLinq = Watch.Elapsed; Console.WriteLine("For the list<T>, took {0} to get all items, for FastLane took {1}.", elapsed4List, elapsed4Collection); Console.WriteLine("For the list<T> with linq, took {0} to get all items, for FastLane took {1}.", elapsed4ListLinq, elapsed4Collection); }
protected void CompareSearch(SortedList <int, MockItem> list, OptimizedCollection <MockItem> collection) { var max = list.Count; Watch.Reset(); int i = 0; Watch.Start(); try { for (i = 1; i < max; i++) { var mockedInList = list[i]; } } catch { Console.WriteLine("index " + i); } Watch.Stop(); var elapsed4List = Watch.Elapsed; Watch.Reset(); var query = collection.Using <UniqueKeyQuery <MockItem, int> >(); Watch.Start(); for (i = 0; i < max; i++) { var mockedInCollection = query.Get(i); } Watch.Stop(); var elapsed4Collection = Watch.Elapsed; Console.WriteLine("For the SortedList<int, T>, took {0} to get one item, for FastLane took {1}.", elapsed4List, elapsed4Collection); }
protected void CompareSearch(SortedList <int, MockItem> list, OptimizedCollection <MockItem> collection) { int key = new Random(new Random().Next(0, list.Count - 1)).Next(0, list.Count - 1); Watch.Reset(); Watch.Start(); var mockedInList = list[key]; Watch.Stop(); var elapsed4List = Watch.Elapsed; Watch.Reset(); Watch.Start(); var mockedInCollection = collection.Using <UniqueKeyQuery <MockItem, int> >().Get(key); Watch.Stop(); var elapsed4Collection = Watch.Elapsed; Console.WriteLine("For the SortedList<int, T>, took {0} to get one item, for FastLane took {1}.", elapsed4List, elapsed4Collection); }