/// <summary> /// Calculates GCD for two or more integer numbers using Stein algorithm. Out parameter returns method execution time /// </summary> /// <param name="executionTime">method execution time in milliseconds</param> /// <param name="numbers">input numbers for calculation</param> /// <returns>GCD for two or more integer numbers </returns> public static int GetSteinGCDWithWatch(out long executionTime, params int[] numbers) { GetGCD getGCD = GetSteinGCD; return(CheckConditionsAndFindGCDWithWatch(out executionTime, getGCD, numbers)); }
/// <summary> /// Calculates GCD for two or more integer numbers. Out parameter returns method execution time /// </summary> /// <param name="executionTime">method execution time in milliseconds</param> /// <param name="getGCD">delegate with target method</param> /// <param name="numbers">input array</param> /// <returns>great common divisor</returns> private static int CheckConditionsAndFindGCDWithWatch(out long executionTime, GetGCD getGCD, params int[] numbers) { getGCD(numbers); var watch = System.Diagnostics.Stopwatch.StartNew(); int result = getGCD(numbers); watch.Stop(); executionTime = watch.ElapsedMilliseconds; return(result); }