[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: Virtual methods?

On Fri, Aug 22, 2003 at 12:10:43AM -0300, Miguel A. Osorio wrote:
> Hey everyone,
> 	I was wondering; how much impact on performance do I get if I use a
> base class that defines a virutal method "Render" and derive all
> "renderable" objects from it? I mean, I'll probably have some loops
> calling the "Render" method for each object. Is this too expensive? Any
> alternatives?

On modern machines you don't need to worry about this. In fact, on
modern machines you shouldn't be worrying about performance on this
level at all.

Really. algorithmic optimisation is far more valuable than worrying
about a tiny overhead like v-method dispatching.

If you haven't written your base object class yet, you're definitely
FAR FAR FAR too early into the development to start worrying about
optimisation at all. Only optimise what you know needs to be
optimised. And you don't know that calling methods need it until you
can performance check them.