Before you cringe at the duplicate title, the other question wasn\'t suited to what I ask here (IMO). So.
I am really wanting to use virtual functions in my applicat
When using too few iterations, there is a lot of noise in the measurement. The gettimeofday
function is not going to be accurate enough to give you good measurements for only a handful of iterations, not to mention that it records total wall time (which includes time spent when preempted by other threads).
Bottom line, though, you shouldn't come up with some ridiculously convoluted design to avoid virtual functions. They really don't add much overhead. If you have incredibly performance critical code and you know that virtual functions make up most of the time, then perhaps it's something to worry about. In any practical application, though, virtual functions won't be what's making your application slow.