3 ms·
Do you have evidence that there is not a profound performance difference between virtual and non-virtual methods? Virtual methods require two memory lookups (th
by NickPollard 14y ago
Do you have evidence that there is not a profound performance difference between virtual and non-virtual methods? Virtual methods require two memory lookups (the vtable address, then the function address) and hence often two cache misses, compared to non-virtual methods which can be static addresses. If you've got a (common in games) loop like:
for ( ..some list of 5000 objects.. ) {
object.update();
}
Then those cache misses will add up. That is my experience anyway, though I'll don't have statistics to back it up