# ulab.fft.spectrogram performance drops for 8192 points and beyond

• Hello,

I am using the custom firmware `LoPy4_pybytes_ulab_sp_thread_v1.20.2.rc10-g87b47d16e_2020-08-06` provided by user @rcolistete (thanks!).

I have a question regarding the speed of the ulab.fft.spectrogram function.

``````import ulab as np
import utime

x=np.arange(2048)
t1=utime.ticks_ms(); y=np.fft.spectrogram(x); t2=utime.ticks_ms(); print(utime.ticks_diff(t2,t1))
12

x=np.arange(4096)
t1=utime.ticks_ms(); y=np.fft.spectrogram(x); t2=utime.ticks_ms(); print(utime.ticks_diff(t2,t1))
25

x=np.arange(8192)
t1=utime.ticks_ms(); y=np.fft.spectrogram(x); t2=utime.ticks_ms(); print(utime.ticks_diff(t2,t1))
866

x=np.arange(16384)
t1=utime.ticks_ms(); y=np.fft.spectrogram(x); t2=utime.ticks_ms(); print(utime.ticks_diff(t2,t1))
1995

x=np.arange(32768)
t1=utime.ticks_ms(); y=np.fft.spectrogram(x); t2=utime.ticks_ms(); print(utime.ticks_diff(t2,t1))
3466
``````

One can see that there is a large increase in computation time between 4096 and 8192 points long arrays.
I would have expected a delay of around 50 ms for a 8192 points array.

Is there any explanation for this?
Anything I could do to get faster computation times for 8192 or even 16384 points long arrays?

Nicolas

• @nteolane
Hi,
Where do you find this "LoPy4_pybytes_ulab_sp_thread_v1.20.2.rc10-g87b47d16e_2020-08-06" ?
I would like to use ulab library but I don't find how ?

• @nteolane My explanation would be RAM cache misses. If the RAM usage exceeds a certain limit, then the RAM cache start to miss and the RAM pages have to be swapped in and out from the cache to the SPI RAM (RAM connected by a SPI bus) each swap takes a few 100 µs.