Consider the following Python code that applies a simple moving average filter to a signal. What is the output of the print statement showing the elapsed time?
import time import numpy as np def moving_average(signal, window_size): return np.convolve(signal, np.ones(window_size)/window_size, mode='valid') signal = np.random.rand(1000000) start = time.perf_counter() filtered = moving_average(signal, 10) elapsed = time.perf_counter() - start print(f"Elapsed time: {elapsed:.4f} seconds")
Think about the time complexity of convolution on a large array.
The moving average uses convolution on a 1 million element array with a window of 10. This typically takes around a tenth of a second on a modern CPU.
Given the following code that creates a large signal and applies a Fourier transform, what is the approximate peak memory usage increase during the FFT operation?
import numpy as np signal = np.random.rand(10**7) # Assume memory profiler measures peak memory during fft fft_result = np.fft.fft(signal)
Consider the size of the input array and the data type used by numpy.
The input array of 10 million floats (float64) uses about 80 MB. The FFT output is complex128, which uses twice the memory, so peak memory increases by about 160 MB.
You run a profiler on a DSP algorithm and get a flame graph showing function call times. Which function is the main bottleneck if it occupies the widest block at the bottom of the graph?
In flame graphs, wider blocks mean more time spent.
The bottom function with the widest block represents the function consuming the most time, thus the main bottleneck.
Which metric is most appropriate to compare the efficiency of two DSP algorithms performing the same task on the same hardware?
Think about what directly measures speed.
Execution time measured by a high-resolution timer directly reflects how fast the algorithm runs, making it the best metric for efficiency comparison.
A DSP engineer notices that repeated runs of the same benchmark code produce varying execution times. Which of the following is the most likely cause?
Consider system-level factors affecting timing consistency.
CPU frequency scaling and background processes cause variability in execution time by changing CPU speed and resource availability.
