Blog post on how wrong I was about how to optimize this ten-line Arduino

Blog post on how wrong I was about how to optimize this ten-line Arduino function:

It goes step-by-step through how I (slowly, confusedly) figured out what was going onside one simple function – without reading the machine code (this was sort of an exercise and demonstration; normally I’d peek inside the generated code).

tl;dr:
(1) In most Arduino code “switch” is rarely faster or smaller than a chain of “if” statements.
(2) Use the smallest data types you can, and don’t let expressions default to 16-bit int’s if you can avoid it, and
(3) Good performance optimization takes some work, but pays off

Awesome article @Mark_Kriegsman , I learned quite a bit from your detailed post, thanks!

Nice read, thanks

Thanks for sharing this. Very useful to watch over your shoulder.

I don’t understand the code, but I can clearly see the route you have taken! Good article!