예제 #1
0
        static void Main(string[] args)
        {
            int dictSize = 200000;

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

            SingleThreadBenchmark.Benchmark(dict, dictSize);

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

            SingleThreadBenchmark.Benchmark(dict2, dictSize);

            Console.WriteLine("\r\nConcurrentDictionary, multiple threads:");
            var dict3 = new ConcurrentDictionary <int, int>();

            ParallelBenchmark.Benchmark(dict3, dictSize);
        }
예제 #2
0
파일: Program.cs 프로젝트: weffer/C-
        static void Main(string[] args)
        {
            // comment out all calls to Worker.DoSomethingTimeConsuming()
            // throughout project to see how the benchmark works when threads spend
            // most of their time dealing with the concurrent dictionary
            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 threads:");
            dict2 = new ConcurrentDictionary <int, int>();
            ParallelBenchmark.TimeDictParallel(dict2, dictSize);
        }