Exemple #1
0
        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!")
            });
Exemple #2
0
 public ValidationResult ValidationResult() => HistoricalData.TryGetValue(sieveSize, out int ival)
     ? (ival == PrimesCount() ? PrimeSieveCS.ValidationResult.Valid : PrimeSieveCS.ValidationResult.Invalid)
     : PrimeSieveCS.ValidationResult.Unkown;
Exemple #3
0
 public ValidationResult IsValid() => HistoricalData.TryGetValue(sieveSize, out int ival)
     ? (ival == PrimesCount ? ValidationResult.Valid : ValidationResult.Invalid)
     : ValidationResult.Unkown;