Hacker News new | ask | show | jobs
by berkut 4586 days ago
I've done benchmarks on this fairly recently, and with the functions actually doing a lot of work (ray intersection for a raytracer), I saw practically no difference between CRTP and Virtual Functions:

http://imagine-rt.blogspot.co.uk/2013/08/c-virtual-function-...

And this was with billions of calls to the functions...

1 comments

Yes, the penalty is most glaring for calls that do a tiny amount of work. Imagine if

  String.charAt(int index)
was a virtual call inside of strlen().