Esempio n. 1
0
 public static void Run(string type, int length, Action<Benchmark> action)
 {
     var data = _dataCreator.GenerateTestData(length);
     Benchmark last = null;
     for (int iterations = 1; last == null || last.Iterations < 1000000 && last.Stopwatch.Elapsed < TimeSpan.FromMilliseconds(500); iterations *= 2)
     {
         var benchmark = new Benchmark();
         benchmark.Iterations = iterations;
         benchmark.Input = data;
         benchmark.Note = "";
         action(benchmark);
         last = benchmark;
     }
     var speed = last.Iterations * (double)data.Length / 1024 / 1024;
     if (speed >= 1000)
         Console.WriteLine("{0} {1}: {2:0.0} GB/s{3}", type, GetSizeText(length), speed / 1024, last.Note);
     else
         Console.WriteLine("{0} {1}: {2:0} MB/s{3}", type, GetSizeText(length), speed, last.Note);
 }