public static void RunTimes(double len, int times = 1) { var primaryStopwatch = Stopwatch.StartNew(); PrimeSieveBA sieve = null; int primesCount = -1; while (times-- > 0) { sieve = new((int)len); sieve.RunSieve(); primesCount = sieve.PrimesCount(); } var isValid = sieve.ValidationResult(); primaryStopwatch.Stop(); WriteLine("Expected primes : ", HistoricalData.TryGetValue((int)len, out int e) ? e.ToString() : "unknown"); WriteLine("Counted primes : ", primesCount); WriteLineSeperator(); WriteLine("Validation-Result : ", isValid, isValid switch { ValidationResult.Unkown => ConsoleColor.DarkGray, ValidationResult.Valid => ConsoleColor.DarkGreen, ValidationResult.Invalid => ConsoleColor.Red, _ => throw new Exception("Invalid validation result!") });
public ValidationResult ValidationResult() => HistoricalData.TryGetValue(sieveSize, out int ival) ? (ival == PrimesCount() ? PrimeSieveCS.ValidationResult.Valid : PrimeSieveCS.ValidationResult.Invalid) : PrimeSieveCS.ValidationResult.Unkown;
public ValidationResult IsValid() => HistoricalData.TryGetValue(sieveSize, out int ival) ? (ival == PrimesCount ? ValidationResult.Valid : ValidationResult.Invalid) : ValidationResult.Unkown;