Exemple #1
0
        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);
        }
Exemple #2
0
        private TimeResults Compare()
        {
            var timeResults = new TimeResults();

            timeResults.Oaat     = GetOaatTime();
            timeResults.AllType  = GetParallelRemovalTime();
            timeResults.Complete = GetCompleteDareTime();
            return(timeResults);
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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);
        }