Example #1
0
 private void DisplayResults()
 {
     foreach (var benchmark in Benchmarks.OrderBy(b => b.Stopwatch.ElapsedMilliseconds))
     {
         Console.WriteLine("{0}: {1} ms -- {2} ms/iteration", benchmark.Name, benchmark.Stopwatch.ElapsedMilliseconds, ((double)benchmark.Stopwatch.ElapsedMilliseconds / (double)IterationCount));
     }
     Console.WriteLine();
 }
Example #2
0
        private void RunBenchmarks()
        {
            var rand = new Random();

            for (int i = 1; i <= IterationCount; i++)
            {
                foreach (var benchmark in Benchmarks.OrderBy(x => rand.Next()))
                {
                    benchmark.Stopwatch.Start();
                    benchmark.Iteration();
                    benchmark.Stopwatch.Stop();
                }
            }
        }