Example #1
0
        private static void InaccurateTimestamping()
        {
            Console.WriteLine("Inaccurate Timestamping");
            Console.WriteLine(@"DateTime - based benchmarks have many problems like pur
                resolution, so it’s better to use Stopwatch for time measurements.");
            Timestamps.SortBad(10000);
            Timestamps.SortBad(10000);
            Timestamps.SortBad(10000);
            Timestamps.SortBetter(10000);
            Timestamps.SortBetter(10000);
            Timestamps.SortBetter(10000);

            Timestamps.SortBad(10);
            Timestamps.SortBad(10);
            Timestamps.SortBad(10);
            Timestamps.SortBetter(10);
            Timestamps.SortBetter(10);
            Timestamps.SortBetter(10);

            Timestamps.SortBad(2);
            Timestamps.SortBad(2);
            Timestamps.SortBad(2);
            Timestamps.SortBetter(2);
            Timestamps.SortBetter(2);
            Timestamps.SortBetter(2);
            Console.WriteLine("Advice: prefer Stopwatch over DateTime");
        }