POV-Ray : Newsgroups : povray.programming : C++ problem : Re: C++ problem Server Time
28 Jul 2024 20:19:34 EDT (-0400)
  Re: C++ problem  
From: Ole Laursen
Date: 30 Jul 2001 14:27:29
Message: <m3u1zu1dcy.fsf@bach.composers>
> > A related misconception is that calling a virtual function is very
> > slow. Yes, it's a bit slower than calling a regular function, but
> > the speed difference is usually one or two CPU clocks, which
> > usually doesn't matter, specially if the function itself takes
> > hundreds of clocks.
> 
> Of course, you assume the vtable is in the cache and the processor supports
> the necessary indirect addressing modes.

I think the most important thing to remember in connection with
virtual functions is that a "hand-crafted" solution will most probably
end up no faster, but a lot more complicated and messy.

The kind of flexibility you get from the dynamically binded functions
simply comes with a cost. Fortunately, that cost probably won't be the
one that slows the program to a crawling halt. :-)

-- 
Ole Laursen
http://sunsite.dk/olau/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.