private static void Ref_Versus_NoRef()
 {
     // No material difference between these two.
     Console.WriteLine($"{BenchmarkUtils.Benchmark(FastFormatRef, _numberOfTimes)} ms for {nameof(FastFormatRef)}");
     Console.WriteLine($"{BenchmarkUtils.Benchmark(FastFormatNoRef, _numberOfTimes)} ms for {nameof(FastFormatNoRef)}");
     Console.WriteLine();
 }
 private static void HardcodedIndexes_Versus_IncrementedSoNoLeadingZeroes()
 {
     // In release mode with optimizations on, hard-coding the char[] indexes takes
     // about 90% as long as incrementing an integer index to account for trailing zeroes.
     // Not really worth it.
     Console.WriteLine($"{BenchmarkUtils.Benchmark(FastFormatRef, _numberOfTimes)} ms for {nameof(FastFormatRef)}");
     Console.WriteLine($"{BenchmarkUtils.Benchmark(FastFormatHardcodedIndexes, _numberOfTimes)} ms for {nameof(FastFormatHardcodedIndexes)}");
     Console.WriteLine();
 }
Ejemplo n.º 3
0
        public static void DoIt()
        {
            int numberOfTimes = 2000;

            Console.WriteLine($"{BenchmarkUtils.Benchmark(GenericDictionary, numberOfTimes)} ms for {nameof(GenericDictionary)}");
            Console.WriteLine($"{BenchmarkUtils.Benchmark(SortedList, numberOfTimes)} ms for {nameof(SortedList)}");
            Console.WriteLine($"{BenchmarkUtils.Benchmark(SortedDictionary, numberOfTimes)} ms for {nameof(SortedDictionary)}");
            Console.WriteLine($"{BenchmarkUtils.Benchmark(Hashtable, numberOfTimes)} ms for {nameof(Hashtable)}");
            Console.WriteLine($"{BenchmarkUtils.Benchmark(ConcurrentDictionary, numberOfTimes)} ms for {nameof(ConcurrentDictionary)}");
        }