Example #1
0
        public void Enumerate()
        {
            var count = 0;

            foreach (var position in _world)
            {
                var ex = _testMap.FirstOrDefault(p => p.X == position.X && p.Y == position.Y);
                Assert.AreEqual(position, ex);
                Assert.IsTrue(_testMap.Contains(position));
                count += 1;
            }
            Assert.AreEqual(count, _testMap.Count);


            var sw = new Stopwatch();

            sw.Start();
            count = _world.Count();
            sw.Stop();
            Assert.AreEqual(count, _testMap.Count);

            Debug.WriteLine($"\n\n\n//ulong enumerate: count:{count}, ticks: {sw.ElapsedTicks }, ms:{sw.ElapsedMilliseconds}\n\n\n");
            //uint enumerate: count:19959, ticks: 7375, ms:3
            //uint enumerate: count:105049, ticks: 37074, ms:19

            //ulong enumerate: count:9940, ticks: 8296, ms:4
            //ulong enumerate: count:19950, ticks: 8976, ms:4
            //ulong enumerate: count:109938, ticks: 71533, ms:36
        }