Performance impact of virtual inheritance

后端 未结 3 670
灰色年华
灰色年华 2020-12-17 08:50

I am considering using virtual inheritance in a real-time application. Does using virtual inheritance have a performance impact similar to that of calling a virtual function

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-17 09:06

    Are you sure you mean virtual inheritance? If so, it's identical to the cost of a normal virtual function call. The vtable chained search just follows a specified path.

    You said that this was at startup. Your disk overhead (from simply loading your code into memory) is likely to require orders of magnitude more time than the half-dozen instructions or so for vtable lookups. I'd be somewhat surprised if you could profile this and detect a difference.

提交回复
热议问题