public void TimeTemplateParsingWithCache()
        {
            ITemplateCache cache = new HashtableTemplateCache();

            int totalRuns = 100;
            DateTime started = DateTime.Now;

            for (int i = 0; i < totalRuns; i++)
            {
                RunStressTests(cache);
            }

            Debug.WriteLine((DateTime.Now - started).TotalMilliseconds / totalRuns);
        }
Esempio n. 2
0
        public void TimeTemplateParsingWithCache()
        {
            ITemplateCache cache = new HashtableTemplateCache();

            const int totalRuns = 100;
            DateTime startedAll = DateTime.Now;

            for (int i = 0; i < totalRuns; i++)
            {
                DateTime started = DateTime.Now;
                RunStressTests(cache);
                Console.WriteLine("Iteration {0} of {1} completed in {2}", i+1, totalRuns, (DateTime.Now - started).Milliseconds);
            }

            TimeSpan ts = DateTime.Now - startedAll;
            Console.WriteLine("Execution completed in {0}, average = {1}", ts.TotalMilliseconds, ts.TotalMilliseconds / totalRuns);
            Console.ReadLine();
        }
Esempio n. 3
0
        public void StressHashtableCache()
        {
            int maxItems = 1000000;
            int maxHits = 1000000;

            Random random = new Random();

            var cache = new HashtableTemplateCache(maxItems);
            cache.Clear();

            for (int i =0;i < maxItems; i++)
                cache.Add("key" + i, new ParseList());

            for( int i=0; i < maxHits; i++)
            {
                cache.Get("key" + random.Next(maxItems));
            }
        }
        public void SimpleTest()
        {
            var cache = new HashtableTemplateCache(3);

            Assert.IsNull(cache.Get("anything"));

            cache.Clear();

            cache.Add("key1", new ParseList());
            cache.Add("key2", new ParseList());
            cache.Add("key3", new ParseList());

            Assert.IsNotNull(cache.Get("key1"));
            Assert.IsNotNull(cache.Get("key2"));
            Assert.IsNotNull(cache.Get("key3"));

            cache.Add("key4", new ParseList());
            object key1Object = cache.Get("key1");
            Assert.IsNull(key1Object);
        }