Sat Oct 28, 2017 11:05 am
So I know how to program in C++ but it was only this year that I had to consider tricks in order
to optimize my code performance. The other little problems I coded were not as intensive as
programming an attitude controller for a quadcopter.
As you can imagine, the associated computations have to be fast. I did some profile performance analysis in
Visual Studio and it pointed out that one my functions was being called 17,000+ times . That definitely cannot be
good for the microcontroller.
The function is included below, it is run in a do-while loop that iterates 50 times; I opted for do-while instead a for loop as
I saw somewhere that it is more performance friendly.
I have read a lot of pages and watched a lot of videos. They have helped with some improved performance but I figured that
looking at what I have done might be best. I tremendously appreciate any advice you might have about this or coding styles in general
. Time is not on my side, deadline
PS, this is the function name from visual studio (I can't make sense of it) and some other details:
Tue Nov 07, 2017 8:45 pm
Hi, some advices:
I don't get the static declarations, they will be computed only at the first call, is it really on purpose?
Otherwise you can optimize T:
For vectors, better call v(i) instead of v(i,0).
Don't use 1x1 matrices, and since T is symmetric better use its columns (sequential access):
For the loop you could try:
To compute al: