Exemplo n.º 1
0
 static void TestAdd(IRepositoryHashSet <int> list, int count)
 {
     for (int i = 0; i < count; ++i)
     {
         list.Add(i);
     }
 }
Exemplo n.º 2
0
 static void TestRemove(IRepositoryHashSet <int> list, int count)
 {
     for (int i = 0; i < count; ++i)
     {
         list.Remove(i);
     }
 }
Exemplo n.º 3
0
        public static void MeasureHashSet(IRepositoryHashSet <int> hashSet, Action <IRepositoryHashSet <int>, int> run)
        {
            int AmountOfTestElenent = 10000000;

            Console.WriteLine("HashSet: additional test");
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            run(hashSet, AmountOfTestElenent); // возможно, 10000 — слишком мало?
            stopWatch.Stop();
            var timeSpan = stopWatch.ElapsedMilliseconds;

            Console.WriteLine(timeSpan);

            stopWatch.Restart();
            TestContains(hashSet, AmountOfTestElenent);
            stopWatch.Stop();
            timeSpan = stopWatch.ElapsedMilliseconds;
            Console.WriteLine(timeSpan);

            stopWatch.Restart();
            TestRemove(hashSet, AmountOfTestElenent);
            stopWatch.Stop();
            timeSpan = stopWatch.ElapsedMilliseconds;
            Console.WriteLine(timeSpan);
            Console.WriteLine();
        }
Exemplo n.º 4
0
        static void TestContains(IRepositoryHashSet <int> list, int count)
        {
            var containsAll = true;

            for (int i = 0; i < count; i++)
            {
                containsAll &= list.Contains(i);
            }
            Debug.Assert(containsAll);
        }