when it comes to optimizations there are several things to consider. it is not always a profitable thing to do to get things to work at the fastest, after all the development time is a consideration. but if you want to make friends it is also best to not require a 200$ piece of a cpu for an otherwise 10$ project. and then prices always get lower. but if you make something efficient it will usually work better on newer hardware and also allow more performance for other cool tasks.
I'll start here with some basics.simple things like:
*always multiply instead if divide.
if possible have the 1/x equivalent is x *0.25
*store variables outside of loop to reduce variable load and unload in stack.
can speed up deep loops over 100% (it does increase ram usage at compile however.)
instead of :
void function(){
float math 1;
float math 2:
...}
do this:
float math 1;
float math 2:
...
function(){
}
*table values when possible. so the math can be done before compile
*if you must / and* try powers of 2., use uint32_t or uint16_t and
Shift >> to lower /2 and shift << to *2
*never just assign int's assign int16_t or int32_t otherwise 8bt and 32bit will not be good friends.
there are several types of math differences in how 16 bit math is done versus 32bit math. this is especially important in multiplication, and in bit shifting. also int default to int32_t on 32 bit and int16_t on 8bit.