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

Re: Virtual methods?

On Fri, 22 Aug 2003, Katie Lucas wrote:

>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.

Yeah, if that's a problem he should also start worrying about the overhead
of methods and functions. The whole game *may* be possible to squeeze into
main(), thus saving a few cycles that nobody ever will notice nor care

>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.

So true. Premature optimization is the root bla bla... It probably just
guarantees that your game is never completed.


             Gravity is a habit that is hard to shake off.
                                              -- Terry Pratchett, Small Gods