static void Main(string[] args) { var tStart = DateTime.UtcNow; var passes = 0; prime_sieve sieve = null; while ((DateTime.UtcNow - tStart).TotalSeconds < 10) { sieve = new prime_sieve(1000000); sieve.runSieve(); passes++; } var tD = DateTime.UtcNow - tStart; if (sieve != null) { sieve.printResults(false, tD.TotalSeconds, passes); } }
static void Main(string[] args) { var stopWatch = new Stopwatch(); var passes = 0; prime_sieve sieve = null; long temMilliseconds = 10 * 1000; stopWatch.Start(); while (stopWatch.ElapsedMilliseconds < temMilliseconds) { sieve = new prime_sieve(1000000); sieve.runSieve(); passes++; } stopWatch.Stop(); if (sieve != null) { sieve.printResults(false, stopWatch.Elapsed.TotalSeconds, passes); } }
static void Main(string[] args) { CultureInfo.CurrentCulture = new CultureInfo("en-US", false); var tStart = DateTime.UtcNow; var passes = 0; prime_sieve sieve = null; while ((DateTime.UtcNow - tStart).TotalSeconds < 5) { sieve = new prime_sieve(1000000); sieve.runSieve(); passes++; } var tD = DateTime.UtcNow - tStart; if (sieve != null) { sieve.printResults(false, tD.TotalSeconds, passes); } }
static void Main(string[] args) { const ulong SieveSize = 1000000; const long MillisecondsPerSecond = 1000; const long MicrosecondsPerSecond = 1000000; ulong passes = 0; prime_sieve sieve = null; var stopwatch = Stopwatch.StartNew(); while (stopwatch.ElapsedMilliseconds < (5 * MillisecondsPerSecond)) { sieve = new prime_sieve(SieveSize); sieve.runSieve(); passes++; } stopwatch.Stop(); if (sieve != null) { sieve.printResults(false, (stopwatch.Elapsed.TotalSeconds * MicrosecondsPerSecond) / SieveSize, passes); } }