private static Tuple <double, double, bool> Run(ISort <MyKeyValue <int, string> > sort, int numberOfItems, int arrayPreparationIndex) { MyKeyValue <int, string>[] numbers = null; Stopwatch wallClock = new Stopwatch(); ProcessUserTime processUserTime = new ProcessUserTime(); switch (arrayPreparationIndex) { case 0: numbers = ArrayExtensions.CreateOrderedMKVArray(numberOfItems); break; case 1: numbers = ArrayExtensions.CreateReverseOrderedMKVArray(numberOfItems); break; case 2: numbers = ArrayExtensions.CreateRandomMKVArray(numberOfItems, new Random()); break; } // Measure the sorting. wallClock.Restart(); processUserTime.Restart(); sort.Sort(numbers); processUserTime.Stop(); wallClock.Stop(); return (new Tuple <double, double, bool>(wallClock.Elapsed.TotalSeconds, processUserTime.ElapsedTotalSeconds, ArrayExtensions.VerifySorted <MyKeyValue <int, string> >(numbers))); }
private static Tuple <double, double> Run(MandelbrotBase mandelbrot) { Stopwatch wallClock = new Stopwatch(); ProcessUserTime processUserTime = new ProcessUserTime(); // Measure the Mandelbrot computation. wallClock.Restart(); processUserTime.Restart(); mandelbrot.Compute(); processUserTime.Stop(); wallClock.Stop(); return (new Tuple <double, double>(wallClock.Elapsed.TotalSeconds, processUserTime.ElapsedTotalSeconds)); }
private static Tuple <double, double, double> Run(IComputePi computePi, int totalNumberOfSteps) { Stopwatch wallClock = new Stopwatch(); ProcessUserTime processUserTime = new ProcessUserTime(); // Measure the computation of Pi. wallClock.Restart(); processUserTime.Restart(); double result = computePi.ComputePi(totalNumberOfSteps); processUserTime.Stop(); wallClock.Stop(); return (new Tuple <double, double, double>(result, wallClock.Elapsed.TotalSeconds, processUserTime.ElapsedTotalSeconds)); }