shaved another 50,000 microseconds off of math time for arduino 328p chip. it does however use 4 more bytes. as it requires another float to store the fractional result
i recently posted a a project about different optimization techniques here
https://hackaday.io/project/167533-math-optimizations-with-specific-tasks-and-ranges
one of my guide rules was whenever possible fractionally multiply instead of divide.
i have broken down the math to its basics, so i can simplify and cache.
i have determined that the first sub_calc_To (my version of the math) still eats up 500,000 microseconds time to process.
this is how the code looks after it has been modified to be simpler
and here is how it looks now with a time savings of 50,000 microseconds
there are some notes and references to the data in the comments. this is more for me.
any way the division has been cached, and the result turned into a fraction, and applied two times.
notice the above version divides twice. the version below divides 1 time. division is at minimum 4 times slower and in many cases a lot longer. multiplication even with floats is faster. this is because even the most basic cpus contain logic for multiplication usually just an extended length register. division is harder beast to incorporate hardware for, so it is done in software very slowly.
removing the division to speed things up. we still need to do it once however. now i just need to check to see if this value happens more than one time! i have noticed that the time it takes to solve increases when more heat is on the cells. i'll look into it more.....
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.