Пример #1
0
        public void Run()
        {
            var tester = new CacheStressTester <object, object>(rng);

            RunTime = tester.TestCache(
                cache,
                generateKey,
                generateValue,
                false,
                true);
        }
Пример #2
0
        public void WeakCacheOverwrite()
        {
            var time = new CacheStressTester <object, object>(rng).TestCache(
                new WeakCache <object, object>(EqualityComparer <object> .Default),
                GenerateInt32Object,
                GenerateInt32Object,
                false,
                true);

            Console.WriteLine("Overwrite weak cache test took " + time);
        }
Пример #3
0
        public void LruCache()
        {
            var time = new CacheStressTester <int, int>(rng).TestCache(
                new LruCache <int, int>(128),
                GenerateInt32,
                GenerateInt32,
                true,
                true);

            Console.WriteLine("LRU cache test took " + time);
        }
Пример #4
0
        public void WeakCacheCleanup2()
        {
            int iterations = 100;
            var cache      = new WeakCache <object, object>();

            for (int i = 0; i < iterations; i++)
            {
                var stressTester = new CacheStressTester <object, object>(
                    rng,
                    CacheStressTester <object, object> .DefaultOpCount / iterations);
                stressTester.TestCache(
                    cache,
                    GenerateInt32Object,
                    GenerateInt32Object,
                    true,
                    false);
                stressTester = null;
                GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                cache.Cleanup();
            }
        }