public double RunBenchmark(BenchmarkData data) { //Run passes double value = 0; for (int i = 0; i < PASS_COUNT; i++) { value += RunBenchmarkPass(data, i); } return(value / PASS_COUNT); }
public double RunBenchmarkPass(BenchmarkData data, int pass) { //Log basic info string logLine = $"Running [PASS {pass}] \"{BenchmarkName}\" ({BenchmarkArgs})..."; Console.Write(logLine + "0%..."); //Prepare PrepareBenchmark((int)data.sampleRate, bufferSize); long logUpdateSamples = 0; int logUpdateIndex = 0; Stopwatch timer = new Stopwatch(); timer.Start(); //Loop for (long sample = 0; sample < data.sampleCount; sample += bufferSize) { //Determine readable int readable = (int)Math.Min(bufferSize, data.sampleCount - sample); //Process ProcessBlock(data.ptr + sample, readable); //Log if needed logUpdateSamples += readable; if (logUpdateSamples > data.samplesPerLogUpdate) { logUpdateIndex++; logUpdateSamples -= data.samplesPerLogUpdate; Console.Write("\r" + logLine + logUpdateIndex + "0%..."); } } //Get time and clean up TimeSpan time = timer.Elapsed; EndBenchmark(); //Log Console.WriteLine("\r" + logLine + $"DONE ({time.TotalSeconds} seconds)"); return(time.TotalSeconds); }
static void Main(string[] args) { //Load file for benchmarking BenchmarkData file = new BenchmarkData(@"C:\Users\Roman\Desktop\Unpacked IQ\93700000Hz 93x no excuses toth.wav", 10, 30); //BenchmarkData file = new BenchmarkData(@"/home/pi/benchmark/benchmark.wav", 10, 30); file.Load(); //Create benchmarks BenchmarkBase[] benchmarks = new BenchmarkBase[] { new WbFmDemodBenchmark(8192, 250000, 48000), new WbFmDemodBenchmark(16384, 250000, 48000), new WbFmDemodBenchmark(32768, 250000, 48000), }; //Process double[] times = new double[benchmarks.Length]; for (int i = 0; i < benchmarks.Length; i++) { times[i] = benchmarks[i].RunBenchmark(file); } //Serialize string[] logLines = new string[times.Length]; for (int i = 0; i < benchmarks.Length; i++) { logLines[i] = $"\"{benchmarks[i].BenchmarkName}\",\"{benchmarks[i].BenchmarkArgs}\",{times[i]}"; } //Prompt for name Console.WriteLine("Benchmarks completed. Choose a filename for this file."); string name = Console.ReadLine(); //Save File.WriteAllLines(name, logLines); }