Performance hit of vtable lookup in C++

前端 未结 6 1186
日久生厌
日久生厌 2020-12-24 03:52

I\'m evaluating to rewrite a piece of real-time software from C/assembly language to C++/assembly language (for reasons not relevant to the question parts of the code are ab

6条回答
  •  执念已碎
    2020-12-24 04:26

    I suggest using static methods in your derived classes and placing these functions into your array. This would eliminate the overhead of the v-table search. This is closest to your C language implementation.

    You may end up sacrificing the polymorphism for speed.
    Is the inheritance necessary?
    Just because you switch to C++ doesn't mean you have to switch to Object Oriented.

    Also, have you tried unrolling your loop in the ISR?
    For example, perform 2 or more execution calls before returning back to the top of the loop.

    Also, can you move any of the functionality out of the ISR? Can any part of the functionality be performed by the "background loop" instead of the ISR? This would reduce the time in your ISR.

提交回复
热议问题