Esempio n. 1
0
        public void CollectionIsFastEnoughForAMillionAddresses(int seed)
        {
            var random    = new Random(seed);
            var addresses = Enumerable.Range(0, 1000000).Select(i => (ulong)random.Next(0x00100000, 0x28000000)).ToArray();

            var collection         = new ObjectAddressSet(GetTestHeapIndex());
            var swObjectAddressSet = Stopwatch.StartNew();

            foreach (var address in addresses)
            {
                collection.Add(address);
            }
            foreach (var address in addresses)
            {
                collection.Contains(address);
            }
            swObjectAddressSet.Stop();

            var hashSet   = new HashSet <ulong>();
            var swHashSet = Stopwatch.StartNew();

            foreach (var address in addresses)
            {
                hashSet.Add(address);
            }
            foreach (var address in addresses)
            {
                hashSet.Contains(address);
            }
            swHashSet.Stop();

            Trace.WriteLine($"ObjectAddressSet: {swObjectAddressSet.Elapsed}");
            Trace.WriteLine($"HashSet<ulong>:   {swHashSet.Elapsed}");
        }
Esempio n. 2
0
 private void CollectChild(ulong a, int _)
 {
     if (a == 0)
     {
         return;
     }
     if (visited.Contains(a))
     {
         return;
     }
     pending.Push(a);
 }