Math operations CPU time
Tests done with a STM8S105 running at 16MHz, SDCC 3.7.0. Interrupts were not running and the time was measured with a pin change signals on oscilloscope.
Int32_t
int32_t = int32_t + int32_t | 3.2us
int32_t = int32_t - int32_t | 3.6us
int32_t = int32_t * int32_t | 14us
int32_t = int32_t / int32_t | 132us
Floats
float = float + float | 75us
float = float - float | 75us
float = float * float | 90us
float = float / float | 175us
Floats and int32_t
float = float + int32_t | 105us
float = float - int32_t | 115us
float = float * int32_t | 130us
float = float / int32_t | 215us
Example of a long operation:
f_8 = (f_1 * f_2 * f_3 * f_4 * f_5) / (f_6 * f_7); f_8 = f_1 * f_8;
the real measured value for that operations: 775us