private static int Benchmarks(bool dotnetBenchmark, bool managedBenchmark, bool nativeBenchmark) { double?managedElapsedMillisecond = null; double?nativeElapsedMillisecond = null; if (dotnetBenchmark) { DotnetBenchmark.Calculate(); } if (managedBenchmark) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("---- MANAGED ----"); Console.ForegroundColor = ConsoleColor.Gray; managedElapsedMillisecond = FftManaged.Calculate(Params.Log2FftSize, Params.FftRepeat); } if (nativeBenchmark) { try { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("---- NATIVE ----"); Console.ForegroundColor = ConsoleColor.Gray; nativeElapsedMillisecond = FftNative.Calculate(Params.Log2FftSize, Params.FftRepeat); } catch (Exception e) { Console.WriteLine($"Can not run native method: {e.Message}"); Console.WriteLine("Have you successfully compiled the project in ../C-tests/C-fast_double/?"); return(1); } } if (managedElapsedMillisecond.HasValue && nativeElapsedMillisecond.HasValue) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"\nRatio: {managedElapsedMillisecond / nativeElapsedMillisecond:0.####}"); Console.WriteLine($"Diff%: {managedElapsedMillisecond / nativeElapsedMillisecond - 1:0.##%}"); Console.ForegroundColor = ConsoleColor.Gray; } return(0); }
public void Native() => FftNative.fft(Params.Log2FftSize, xyNative, xyOutNative);