The Cost of Dynamic (Virtual Calls) vs. Static (CRTP) Dispatch in C++ -- Eli Bendersky

eli-bendersky.PNGA nice dive into performance costs on at least one compiler, and on the difficulties of doing meaningful performance measurements on modern hardware. Be sure to read the short comment thread too.

The Cost of Dynamic (Virtual Calls) vs. Static (CRTP) Dispatch in C++

by Eli Bendersky

From the article:

A couple of years ago I wrote an article about the Curiously Recurring Template Pattern in C++, focusing on the motivation behind it and how to implement it.

That article mentioned runtime performance as the main reason for employing CRTP instead of the more traditional runtime polymorphism (dispatch via virtual functions). While some rationale for the cost of virtual calls was given, I didn’t go too deep into it. Today I want to fix that by carefully analyzing the performance of virtual calls as opposed to the static calls made possible by CRTP.

Mandatory precaution about benchmarks

Benchmarking in 2013 is really hard. ...

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.