Ejemplo n.º 1
0
        public async Task AddSpeed()
        {
            const int count = 5_000_000;

            for (int r = 0; r < 10; r++)
            {
                var sl  = new SortedList <int, int>();
                var sm  = new SortedMap <int, int>();
                var scm = new SortedChunkedMap <int, int>();

                var c = sm.GetCursor();

                sm._isSynchronized  = false;
                scm._isSynchronized = false;

                using (Benchmark.Run("SL", count))
                {
                    for (int i = 0; i < count; i++)
                    {
                        if (i != 2)
                        {
                            sl.Add(i, i);
                        }
                    }
                }

                using (Benchmark.Run("SM", count))
                {
                    for (int i = 0; i < count; i++)
                    {
                        if (i != 2)
                        {
                            await sm.TryAdd(i, i);
                        }
                    }
                }

                using (Benchmark.Run("SCM", count))
                {
                    for (int i = 0; i < count; i++)
                    {
                        if (i != 2)
                        {
                            await scm.TryAdd(i, i);
                        }
                    }
                }
                scm.Dispose();
            }

            Benchmark.Dump();
        }