Member hooks and base hooks in intrusive data structures

I am coding an obsessive data structure and wondering whether to use basic or custom interceptors. Since the code will be called many times, my question is about performance and to what extent compilers can embed such code.

Base hooks are based on inheritance, while hook elements use member pointers through template parameters. My design choice would be to use element hooks, but my experience says pointers are much harder to optimize than static code. On the other hand, all of these pointers are known at compile time, and perhaps the compiler can do some magic to analyze what happens.

Does anyone have any experience? Any data, tips or links are welcome.

+3
source share
2 answers

Like for most "X vs Y, which is faster?" questions there is only one correct answer for this:

Set your profiler.

Experience is unclear. Human guesses cannot take into account all the detailed details and pitfalls of compiler optimization. Compilers differ in that they can optimize and how well they do it. Sometimes even between different versions of the same compiler. The only thing that can tell you how your implementations can be optimized by your specific compiler (s) on your specific platform (s) is a proper performance measurement with typical problem sizes.

-, , , , : , ? , ? ? , .

0

"" , . , , .

.

-1

All Articles