Main profiling function
| 86 | |
| 87 | // Main profiling function |
| 88 | int runProfiler(bool jsonOutput) { |
| 89 | using clock = fl::chrono::high_resolution_clock; |
| 90 | |
| 91 | const int ITERATIONS = 1000; |
| 92 | const int SAMPLE_RATE = 16000; |
| 93 | |
| 94 | fl::vector<DetectorBenchmark> benchmarks; |
| 95 | SynthAudioGenerator audioGen(SAMPLE_RATE); |
| 96 | |
| 97 | // Create audio processor (which owns all detector) |
| 98 | fl::audio::Processor processor; |
| 99 | processor.setSampleRate(SAMPLE_RATE); |
| 100 | |
| 101 | // Register some callbacks to ensure detector are active |
| 102 | // (Lazy detector don't update if no callbacks are registered) |
| 103 | processor.onEnergy([](float) {}); // EnergyAnalyzer (BASELINE) |
| 104 | processor.onFrequencyBands([](float, float, float) {}); // FrequencyBands |
| 105 | processor.onBeat([]() {}); // Beat |
| 106 | processor.onTempo([](float) {}); // TempoAnalyzer |
| 107 | processor.onPitch([](float) {}); // Pitch |
| 108 | processor.onVocal([](fl::u8) {}); // Vocal |
| 109 | processor.onMood([](const fl::Mood&) {}); // MoodAnalyzer |
| 110 | processor.onTransient([]() {}); // Transient |
| 111 | processor.onVibeLevels([](const fl::audio::detector::VibeLevels&) {}); // Vibe |
| 112 | |
| 113 | // Warm-up (JIT/caching) |
| 114 | for (int i = 0; i < 10; i++) { |
| 115 | fl::audio::Sample sample = audioGen.generateSample(); |
| 116 | processor.update(sample); |
| 117 | } |
| 118 | |
| 119 | // Benchmark: Measure total time for ITERATIONS updates |
| 120 | auto t0 = clock::now(); |
| 121 | |
| 122 | for (int i = 0; i < ITERATIONS; i++) { |
| 123 | fl::audio::Sample sample = audioGen.generateSample(); |
| 124 | processor.update(sample); |
| 125 | } |
| 126 | |
| 127 | auto t1 = clock::now(); |
| 128 | fl::i64 totalTimeNs = |
| 129 | fl::chrono::duration_cast<fl::chrono::nanoseconds>(t1 - t0).count(); |
| 130 | |
| 131 | // For now, report combined time |
| 132 | // (Detailed per-detector timing would require instrumenting Processor) |
| 133 | DetectorBenchmark overall; |
| 134 | overall.name = "Processor (all detector)"; |
| 135 | overall.totalTimeNs = totalTimeNs; |
| 136 | overall.iterations = ITERATIONS; |
| 137 | benchmarks.push_back(overall); |
| 138 | |
| 139 | if (jsonOutput) { |
| 140 | // Output JSON format for integration with profiling pipeline |
| 141 | ProfileResultBuilder::print_result("baseline", "audio_processors", ITERATIONS, |
| 142 | static_cast<fl::u32>(totalTimeNs / 1000)); |
| 143 | } else { |
| 144 | // Output human-readable report |
| 145 | fl::printf("\n"); |
no test coverage detected