static void SimpleTimerMedium() { Console.WriteLine("Simple - Timer - Medium"); Console.WriteLine("ArraySize;Time[s]"); SearchClass sc = new SearchClass(); Random rand = new Random(); for (long i = 2000000; i <= (long)Math.Pow(2, 28); i += 2000000) { long min = long.MaxValue; long max = long.MinValue; long total = 0; for (int j = 0; j < 12; j++) { int[] arr = CreateAndFillArray(i); long start = Stopwatch.GetTimestamp(); sc.SimpleSearch(arr, rand.Next(0, 1000)); long stop = Stopwatch.GetTimestamp(); long difference = stop - start; total += difference; if (difference > max) { max = difference; } if (difference < min) { min = difference; } } Console.WriteLine("{0};{1}", i, (total - (max + min)) / 10); } }
static void SimpleTimerPesymistic() { Console.WriteLine("Simple - Timer - Pesymistic"); Console.WriteLine("ArraySize;Time[s]"); SearchClass sc = new SearchClass(); for (long i = 2000000; i <= (long)Math.Pow(2, 28); i += 2000000) { int[] arr = CreateAndFillArray(i); long start = Stopwatch.GetTimestamp(); sc.SimpleSearch(arr, 1001); long stop = Stopwatch.GetTimestamp(); Console.WriteLine("{0};{1}", i, (stop - start) * (1.0 / Stopwatch.Frequency)); } }