public void CompareTimes(TextWriter tw) { tw.WriteLine("Program name, OneAtATimeRemover (ms), CompleteRemover (ms), AllTypeSimultaneousRemover (ms)"); List <TimeResults> results = new List <TimeResults>(); foreach (var program in _programs) { try { Console.WriteLine("Comparing " + program.Name); var timeComparer = new TimeComparer(program); var result = timeComparer.CompareTimes(_numberOfRuns); tw.WriteLine("{0},{1},{2},{3}", program.Name, result.Oaat, result.Complete, result.AllType); results.Add(result); } catch (NotValidException) { Console.WriteLine("Program {0} was not valid at initialisation", program.Name); } catch (Exception e) { Console.WriteLine("Program {0} failed: {1}", program.Name, e.Message); } } var avgResults = TimeResults.GetAverageResults(results); tw.WriteLine("Average,{0},{1},{2}", avgResults.Oaat, avgResults.Complete, avgResults.AllType); }
private TimeResults Compare() { var timeResults = new TimeResults(); timeResults.Oaat = GetOaatTime(); timeResults.AllType = GetParallelRemovalTime(); timeResults.Complete = GetCompleteDareTime(); return(timeResults); }
public TimeResults CompareTimes(int numberOfRuns = 3) { var timeResults = new List <TimeResults>(); for (int i = 0; i < numberOfRuns; i++) { timeResults.Add(Compare()); } return(TimeResults.GetAverageResults(timeResults)); }
public static TimeResults GetAverageResults(List <TimeResults> timeResults) { var numberOfRuns = timeResults.Count; var avgResults = new TimeResults(); foreach (var result in timeResults) { avgResults.Oaat += result.Oaat; avgResults.AllType += result.AllType; avgResults.Complete += result.Complete; } avgResults.Oaat /= numberOfRuns; avgResults.AllType /= numberOfRuns; avgResults.Complete /= numberOfRuns; return(avgResults); }