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

Function printAccuracyReport

tests/profile/fft_cq_compare.cpp:204–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202static const int NUM_MODES = 4;
203
204static void printAccuracyReport(int samples, int bands, float fmin,
205 float fmax, int sampleRate) {
206 const float testFreqs[] = {200.0f, 330.0f, 440.0f, 660.0f, 880.0f,
207 1000.0f, 1500.0f, 2000.0f, 3000.0f, 4000.0f};
208 const int nFreqs = 10;
209
210 fl::vector<AccuracyResult> results;
211
212 fl::printf("======================================================\n");
213 fl::printf(" FFT Mode Accuracy Comparison\n");
214 fl::printf("======================================================\n");
215
216 for (int m = 0; m < NUM_MODES; m++) {
217 runAccuracyTest(MODES[m].mode, MODES[m].label, samples, bands,
218 fmin, fmax, sampleRate, testFreqs, nFreqs, results);
219 }
220
221 fl::printf("\n--- %.1f-%.1f Hz, %d bins ---\n", fmin, fmax, bands);
222 fl::printf("%-12s %8s %8s %8s %6s %8s\n",
223 "Mode", "SineHz", "ExpHz", "GotHz", "BinErr", "Leakage");
224 fl::printf("-------------------------------------------------------------\n");
225 for (const auto &r : results) {
226 fl::printf("%-12s %7.0f %8.1f %8.1f %5d %6.1f%%\n",
227 r.modeName, r.testFreq, r.expectedBinFreq,
228 r.actualBinFreq, r.binError, r.leakage * 100.0f);
229 }
230
231 // Average leakage per mode
232 fl::printf("\n--- Average Leakage by Mode ---\n");
233 for (int m = 0; m < NUM_MODES; m++) {
234 float totalLeak = 0.0f;
235 int count = 0;
236 for (const auto &r : results) {
237 if (fl::strcmp(r.modeName, MODES[m].label) == 0) {
238 totalLeak += r.leakage;
239 count++;
240 }
241 }
242 if (count > 0) {
243 fl::printf(" %-12s avg leakage: %5.1f%%\n", MODES[m].label,
244 totalLeak / static_cast<float>(count) * 100.0f);
245 }
246 }
247 fl::printf("\n");
248}
249
250static void benchSignal(const char *signalName,
251 fl::span<const fl::i16> signal, int bands,

Callers 1

runBenchmarkFunction · 0.85

Calls 3

printfFunction · 0.85
runAccuracyTestFunction · 0.85
strcmpFunction · 0.85

Tested by

no test coverage detected