private static void MultiThreadedBenchmark(int dictSize)
        {
            Console.WriteLine("\r\nConcurrentDictionary, multiple threads: ");
            var dict = new ConcurrentDictionary <int, int>();

            ParallelBenchmark.TimeDictParallel(dict, dictSize);
        }
示例#2
0
        static void Main(string[] args)
        {
            int dictSize = 1000000;

            Console.WriteLine("Dictionary, single thread:");
            var dict = new Dictionary <int, int>();

            SingleThreadBenchmark.TimeDict(dict, dictSize);

            Console.WriteLine("\r\nConcurrentDictionary, single thread:");
            var dict2 = new ConcurrentDictionary <int, int>();

            SingleThreadBenchmark.TimeDict(dict2, dictSize);

            Console.WriteLine("\r\nConcurrentDictionary, multiple thread:");
            dict2 = new ConcurrentDictionary <int, int>();
            ParallelBenchmark.TimeDict(dict2, dictSize);
        }