From kde-devel Wed Sep 20 08:23:45 2006 From: Guillaume Laurent Date: Wed, 20 Sep 2006 08:23:45 +0000 To: kde-devel Subject: Re: c++ question: code duplication across classes Message-Id: <4510FA91.9080304 () telegraph-road ! org> X-MARC-Message: https://marc.info/?l=kde-devel&m=115874064611068 Thiago Macieira wrote: > Benoît Jacob wrote: > >> is the overhead for virtual methods a speed overhead ? >> > > The overhead of a virtual method is an indirect jump (instead of a direct > one). This used to be a problem because it would throw off all prediction > done in modern CPUs, because they didn't predict indirect branches. I > don't know if that's still true. > > So, if you can, avoid virtuals if speed is an issue. > Last time I tried to measure the speed overhead of a virtual method, that was about 3 years ago on a Pentium 3, and it would take millions of calls for the overhead to be noticeable. Which is quite possible when doing computations in a large matrix. -- Guillaume http://telegraph-road.org >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<