From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_20,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,c52c30d32b866eae X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,2ea02452876a15e1 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,c52c30d32b866eae X-Google-Attributes: gid1108a1,public From: rmartin@oma.com (Robert C. Martin) Subject: Re: Real OO Date: 1996/04/09 Message-ID: #1/1 X-Deja-AN: 146604722 references: <65lDeVZF3RB@herold.franken.de> followup-to: comp.lang.eiffel,comp.lang.ada,comp.object organization: Object Mentor newsgroups: comp.lang.eiffel,comp.lang.ada,comp.object Date: 1996-04-09T00:00:00+00:00 List-Id: Don Harrison (donh@syd.csa.com.au) wrote: : To get a real idea of (theoretical) relative performance of : dynamic binding compared to static binding, you need to know: : 1) What is the relative performance of indirect calls as a : fraction of the performance of direct calls. Are they 50% as : efficient?, 40%?, 60%?, 70%?. I recently conducted just such an experiment in C++. class F { public: void nv(); virtual void v(); }; void F::nv() {} void F::v() {} F f; F& fr=f; fr.nv(); fr.v(); Executing this on a 486-33 laptop I found that the call to nv took 998ns and the call to v took 1142ns, or 144 extra nanoseconds. The compiler was Borland 4.1. On the other hand, I benchmarked this same test on a popular compiler for the 68000. The machine was proprietary, and so I cannot give you the exact environment. However the timings were telling. nv required about 2000ns, and v required 4000ns. Nearly a doubling. It seems clear that the performance delta between virtual and non-virtual functions can vary significantly between compilers. -- Robert Martin | Design Consulting | Training courses offered: Object Mentor Assoc.| rmartin@oma.com | OOA/D, C++, Advanced OO 14619 N. Somerset Cr| Tel: (847) 918-1004 | Mgt. Overview of OOT Green Oaks IL 60048 | Fax: (847) 918-1023 | http://www.oma.com