During application design, you need to know what to expect from the SBC in terms of computation speed to design an application that can process all coming data.
In this tutorial we present a method to measure SBC performance in different tasks and how to extrapolate it to size your application.
Measuring the code
To measure the code we use simple functions that compute the required time to send or receive a bunch of bytes. With that info we have enough to compute CPU usage and size an application.
Below we give you an example to benchmark GPS write operations. It simply sends dummy data to the GPS and measures its time. The return value has units of [bytes/second]
def benchmark_gps_write( chunk=64, N=128, baudrate=921600 ): gps = sbc.Gps( 1, baudrate ) buf = bytearray( chunk ) t0 = time.ticks_us() for i in range( N ): # send len(buf) bytes N times gps.write( buf ) t1 = time.ticks_us() dt_s = time.ticks_diff( t1, t0 )*1e-6 # Compute time size_bytes = chunk*N return size_bytes/dt_s
CPU usage computation
As shown in the table the SBC can send 88[KB/s] to the GPS, using the 100% of CPU. It also means that if your application sends 8.8[KB/s] to the GPS, it uses the 10% of CPU.
The same idea can be applied to any application to get an approximation of the CPU usage and size your application correctly.