Ejemplo n.º 1
0
        private static long IntNTreeGet <V>(IntNTree <V> tree, int key, int times)
        {
            V   ignored   = default(V);
            var treeWatch = Stopwatch.StartNew();

            for (int i = 0; i < times; i++)
            {
                ignored = tree.GetValueOrDefault(key);
            }

            treeWatch.Stop();
            GC.KeepAlive(ignored);
            GC.Collect();
            return(treeWatch.ElapsedMilliseconds);
        }
Ejemplo n.º 2
0
        private static long IntNTreeAdd <V>(ref IntNTree <V> tree, int[] keys, int key, V value)
        {
            var ignored  = default(V);
            var treeTime = Stopwatch.StartNew();

            for (var i = 0; i < keys.Length; i++)
            {
                Interlocked.Exchange(ref tree, tree.AddOrUpdate(keys[i], ignored));
            }

            Interlocked.Exchange(ref tree, tree.AddOrUpdate(key, value));

            treeTime.Stop();
            GC.Collect();
            return(treeTime.ElapsedMilliseconds);
        }