## 4 Test Scenario: AC Signal Analysis of the Sum of 4 Sines with Arbitrary Frequencies
### Processing Time  
In Section 3.1, the asymptotic complexity and the expected runtime as a function of the number of samples and frequency components were presented. However, as mentioned before, the actual processing time may differ due to the different optimization on the hardware/software side. According to Section 3.1, the proposed scenario falls in the ambiguous region where Goertzel, DTFT, and FFT should have similar asymptotic computations, with an advantage for Goertzel and DTFT. They are then followed by linear sine-fit, nonlinear sine-fit, and cross-correlation ranked according to their ascending computational complexity. Nevertheless, it is important to consider the number of iterations, including overhead operations before or during the calculation process. This includes the computation of look-up tables, twiddle factors, and the computation of in-place coefficients for each algorithm. In fact, DTFT actually requires \(14N_{f}\) up to \(18N_{f}\) per iteration, while FFT Radix 2 only requires \(5 log_{2}N\). Therefore, for this test scenario, \(55N\) operations are required for the FFT and \(56N\)-\(72N\) operations for the DTFT. The Goertzel filter requires only \(6N_{f}\) operations per iteration, resulting in \(24N\) total operations, which should make it the fastest algorithm for this test scenario. As shown in Table 7, MATLAB results show that FFT is the fastest owing to the optimized FFTW3 library with a total processing time of 0.51 ms, followed by Goertzel (7.92 ms), then sine-fit linear (8.02 ms), then DTFT (10.98 ms), then cross-correlation (76.64 ms), and finally sine-fit (non-linear) (91.08 ms). On the other hand, the results of Visual C++ match the expected theoretical results, as Goertzel filter is the fastest with 0.51 ms processing time, followed by FFT (0.81 ms), then DTFT (0.92 ms), then Sine-fit (2.1 ms), then sine-fit non-linear (70.39 ms), and finally cross-correlation (377.95 ms). Table 8 shows the comparison between the native double-precision code implementation of the algorithm in STM32, native code implementation in Teensy, and STM32 optimized using CMSIS DSP library. In STM32 native implementation, Goertzel is the fastest algorithm with 21 ms runtime, followed by FFT with 99 ms, then DTFT with 132 ms, then sine-fit (linear) with 638 ms, then sine-fit (non-linear) with 58 s, and finally cross-correlation with 67 s. The same rank is seen for Teensy 3.6 implementation. However, this rank changes when the methods are implemented using CMSIS-DSP on STM32: FFT is the fastest with 8 ms runtime, followed by Goertzel with 18 ms, then DTFT with 28 ms, then sine-fit (linear) with 139 ms, then cross-correlation with 4 s, and finally sine-fit (non-linear) with 12 s.  
At this point, it can be stated that the influence of hardware and software should not be underestimated. However, for native PC (Visual C++) and embedded implementations, the rank of each method is the same on each platform, which is consistent with the theore \begin{table}
\begin{tabular}{c c c} \hline \hline
**-** & **MATLAB** & **PC/C (Visual C++)** \\ \hline FFT & 0.51 & 0.81 \\ Goertzel & 7.92 & 0.51 \\ X-corr & 76.64 & 377.95 \\ Sine-fit (linear) & 8.02 & 2.10 \\ Sine-fit (non-linear) & 91.08 & 70.39 \\ DTFT & 10.98 & 0.92 \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Total AC signal analysis Processing Time as Implemented in MATLAB and Visual C++ in ms.  
ical values in Figure 6. For the hardware-accelerated CMSIS implementation, the mixed radix implementation together with hardware acceleration was able to push DTFT behind FFT. Finally, during the experimentation, we noticed that all algorithms showed a slowdown when implemented with single-precision float functions, i.e., cost and sinf, and that the CMSIS DSP library provides the fastest solutions for trigonometric operations. As a partial conclusion: For this or a similar scenario, when the number of frequencies is small and when using a hardware-accelerated calculation, FFT is the fastest option for AC signal analysis.