예제 #1
0
 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}");
 }
예제 #2
0
        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}");
        }