Esempio n. 1
0
        private static long IntHashTrieGet <V>(IntHashTrie <V> trie, int key, int times)
        {
            V   ignored = default(V);
            var watch   = Stopwatch.StartNew();

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

            watch.Stop();
            GC.KeepAlive(ignored);
            GC.Collect();
            return(watch.ElapsedMilliseconds);
        }
Esempio n. 2
0
        private static long IntHashTrieAdd(ref IntHashTrie <string> trie, int[] keys, int key, string value)
        {
            var ignored  = "ignored";
            var treeTime = Stopwatch.StartNew();

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

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

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