Registered Member
|
Hello guys,
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 coming up PS, this is the function name from visual studio (I can't make sense of it) and some other details:
Thank you!!! |
Moderator
|
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:
|
Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]