MCPcopy Create free account
hub / github.com/FastLED/FastLED / runBenchmark

Function runBenchmark

tests/profile/fft_cq_compare.cpp:263–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263int runBenchmark(bool jsonOutput) {
264 const int SAMPLES = 512;
265 const int SAMPLE_RATE = 44100;
266 const int ITERATIONS = 2000;
267 const float fmin = Args::DefaultMinFrequency();
268 const float fmax = Args::DefaultMaxFrequency();
269 const int bands = 64;
270
271 fl::vector<fl::i16> sines;
272 generateTestSignal(sines, SAMPLES, SAMPLE_RATE);
273 fl::vector<fl::i16> white;
274 generateWhiteNoise(white, SAMPLES);
275 fl::vector<fl::i16> pink;
276 generatePinkNoise(pink, SAMPLES);
277
278 if (jsonOutput) {
279 fl::span<const fl::i16> signals[] = {sines, white, pink};
280 const char *names[] = {"sines", "white", "pink"};
281 for (int s = 0; s < 3; s++) {
282 BenchResult r = benchMode(Mode::CQ_HYBRID, names[s], signals[s],
283 bands, fmin, fmax, SAMPLE_RATE,
284 ITERATIONS);
285 ProfileResultBuilder::print_result(
286 "baseline", r.name, r.iterations,
287 static_cast<fl::u32>(r.totalNs / 1000));
288 }
289 } else {
290 fl::printf("\n");
291 fl::printf("======================================================\n");
292 fl::printf(" FFT Mode Performance Comparison\n");
293 fl::printf("======================================================\n");
294 fl::printf("\n");
295 fl::printf("Config: %d samples, %d Hz, %d bands, %.0f-%.0fHz\n",
296 SAMPLES, SAMPLE_RATE, bands, fmin, fmax);
297 fl::printf("Iterations: %d per measurement\n", ITERATIONS);
298 fl::printf("\n");
299
300 fl::printf(" %-8s", "Signal");
301 for (int m = 0; m < NUM_MODES; m++) {
302 fl::printf(" %8s", MODES[m].label);
303 }
304 fl::printf("\n");
305 fl::printf(" --------------------------------------------------\n");
306
307 benchSignal("sines", sines, bands, fmin, fmax, SAMPLE_RATE,
308 ITERATIONS);
309 benchSignal("white", white, bands, fmin, fmax, SAMPLE_RATE,
310 ITERATIONS);
311 benchSignal("pink", pink, bands, fmin, fmax, SAMPLE_RATE,
312 ITERATIONS);
313
314 fl::printf("\n (all values in us/call)\n");
315
316 // Head-to-head: LOG_REBIN vs HYBRID in same timing window
317 {
318 Args argsLR(SAMPLES, bands, fmin, fmax, SAMPLE_RATE,
319 Mode::LOG_REBIN);
320 Args argsHY(SAMPLES, bands, fmin, fmax, SAMPLE_RATE,

Callers 1

mainFunction · 0.85

Calls 9

generateTestSignalFunction · 0.85
generateWhiteNoiseFunction · 0.85
generatePinkNoiseFunction · 0.85
benchModeFunction · 0.85
printfFunction · 0.85
benchSignalFunction · 0.85
printAccuracyReportFunction · 0.85
microsFunction · 0.50
runMethod · 0.45

Tested by

no test coverage detected