Why is micros() so much slower than millis()?

The millis() function only reads the variables already accumulated by the Timer0 overflow ISR and just returns their values.
The micros() function reads the current counter value of Timer0 and calculates the elapsed time, because return value need even higher time resolution.

Therefore, the execution time of the micros() function is considerably longer than millis() function.

The detailed code can be found below.

millis()

micros()

1 Like