public void MeasureTime() { int length = Editions.Count - 1; int[] indexes = { 0, length, length / 2, length + 1 }; foreach (var index in indexes) { var searcherMagazine = GetMegazine(index); var searcherEdition = searcherMagazine.Edition; Console.WriteLine("----------------------------"); var start = Environment.TickCount; var answer = Editions.Contains(searcherEdition); var end = Environment.TickCount; Console.WriteLine("List edition at index {0}: " + (end - start) + " {1}", index, answer); start = Environment.TickCount; answer = Text.Contains(searcherEdition.ToString()); end = Environment.TickCount; Console.WriteLine("List edition toString at index {0}: " + (end - start) + " {1}", index, answer); start = Environment.TickCount; answer = EdMagDictionary.ContainsKey(searcherEdition); end = Environment.TickCount; Console.WriteLine("Dictionary<Edition, Magazine> key at index {0}: " + (end - start) + " {1}", index, answer); start = Environment.TickCount; answer = EdMagDictionary.ContainsValue(searcherMagazine); end = Environment.TickCount; Console.WriteLine("Dictionary<Edition, Magazine> value at index {0}: " + (end - start) + " {1}", index, answer); start = Environment.TickCount; answer = StMagDictionary.ContainsKey(searcherEdition.ToString()); end = Environment.TickCount; Console.WriteLine("Dictionary<string, Magazine> key at index {0}: " + (end - start) + " {1}", index, answer); start = Environment.TickCount; answer = StMagDictionary.ContainsValue(searcherMagazine); end = Environment.TickCount; Console.WriteLine("Dictionary<string, Magazine> value at index {0}: " + (end - start) + " {1}", index, answer); } }
internal void Reuse() { //Can be updated by application so refill the lists Result = null; _idBlockFun = _magicDatabase.GetAllBlocks().Where(b => b.Name.IndexOf("Fun", StringComparison.InvariantCultureIgnoreCase) >= 0).Select(b => b.Id).First(); _idBlockOnlineOnly = _magicDatabase.GetAllBlocks().Where(b => b.Name.IndexOf("OnlineOnly", StringComparison.InvariantCultureIgnoreCase) >= 0).Select(b => b.Id).First(); Editions = _magicDatabase.GetAllEditionsOrdered(); Collections = _magicDatabase.GetAllCollections(); IEdition[] editions = EditionsSelected.ToArray(); foreach (IEdition edition in editions.Where(edition => !Editions.Contains(edition))) { EditionsSelected.Remove(edition); } ICardCollection[] collections = CollectionsSelected.ToArray(); foreach (ICardCollection collection in collections.Where(collection => !Collections.Contains(collection))) { CollectionsSelected.Remove(collection); } }