private static void SyncOperations(ComputeSync lComputeSync, ulong[] lNumbers, Stopwatch lStopwatch) { lStopwatch.Restart(); foreach (ulong number in lNumbers) { Console.WriteLine(lComputeSync.GetFactorial(lComputeSync.GetFibonacci(number))); } Console.WriteLine($"Sync ops: {lStopwatch.ElapsedMilliseconds}"); }
private static void ParallelOperations(ComputeSync lComputeSync, ulong[] lNumbers, Stopwatch lStopwatch) { CancellationTokenSource tokenSource = new CancellationTokenSource(200); lStopwatch.Restart(); Parallel.ForEach(lNumbers, number => Console.WriteLine(lComputeSync.GetFactorial(lComputeSync.GetFibonacci(number)))); Console.WriteLine($"Parallel ops: {lStopwatch.ElapsedMilliseconds}"); }