List<Performance> GetSieveOfErathosthenesPeformanceTimes(long to, long increment) { var performanceValues = new List<Performance>(); for (long i = 1000; i <= to; i += increment) { Stopwatch sw = new Stopwatch(); var trialDivison = new SieveOfEratosthenes(i); sw.Start(); long prime = trialDivison.Primes.ToList().Last(); var per = new Performance { RangeLimit = i, TimeTaken = sw.ElapsedMilliseconds }; performanceValues.Add(per); } return performanceValues; }
List<Performance> GetTrialDivisonPeformanceTimes(long to, long increment) { var performanceValues = new List<Performance>(); for (long i = 1000; i <= to; i += increment) { Stopwatch sw = new Stopwatch(); var trialDivison = new TrialDivisionByPrimes(); sw.Start(); long prime = trialDivison.Primes.TakeWhile(p => p < i).ToList().Last(); var per = new Performance { RangeLimit = i, TimeTaken = sw.ElapsedMilliseconds }; performanceValues.Add(per); } return performanceValues; }