 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Graham Banks Guest
|
Posted: Wed Jul 30, 2003 1:32 pm Post subject: Multiple inheritance performance hit |
|
|
Does using multiple inheritance introduce any more performance overhead than
single inheritance?
|
|
| Back to top |
|
 |
tom_usenet Guest
|
Posted: Wed Jul 30, 2003 4:30 pm Post subject: Re: Multiple inheritance performance hit |
|
|
On Wed, 30 Jul 2003 14:32:45 +0100, "Graham Banks"
<grahambanksRemoveIfYouAreNotASpamBot (AT) sol-digi (DOT) com> wrote:
| Quote: | Does using multiple inheritance introduce any more performance overhead than
single inheritance?
|
It depends on the implementation, but calling a virtual function where
virtual multiple inheritence is involved will typically be slightly
slower than a normal virtual function. The vtable for a class involved
in multiple inheritence will probably be larger too.
Tom
|
|
| Back to top |
|
 |
Alex Vinokur Guest
|
Posted: Mon Aug 04, 2003 5:14 pm Post subject: Re: Multiple inheritance performance hit |
|
|
"Graham Banks" <grahambanksRemoveIfYouAreNotASpamBot (AT) sol-digi (DOT) com> wrote
| Quote: | Does using multiple inheritance introduce any more performance overhead than
single inheritance?
|
Multiple inheritance vs. single inheritance
===========================================
C/C++ Performance Tests
=======================
Using C/C++ Program Perfometer
http://sourceforge.net/projects/cpp-perfometer
http://alexvn.freeservers.com/s1/perfometer.html
Environment
-----------
Windows 2000 Professional
CYGWIN_NT-5.0 1.3.22(0.78/3/2)
Intel(R) Celeron(R) CPU 1.70 GHz
GNU gcc/g++ version 3.2 20020927 (prerelease)
Compilation : No optimization
===================== Classes : BEGIN =====================
====================
Hierarchy of classes
====================
Foo0
| Quote: |
Foo1
_____________|_____________
|
__________|__________ |
| |
| |
Foo2_v1 Foo2_v2 Foo2
| |
___________________| |
|
|
Foo3_m Foo3
|
|
Foo4_m Foo4 |
=====================
Definition of classes
=====================
// --------------
class Foo0
{
public:
Foo0 () {}
};
// --------------
class Foo1 : public Foo0
{
public:
Foo1 () : Foo0 () {}
};
// --------------
class Foo2_v1 : virtual public Foo1
{
public:
Foo2_v1 () : Foo1 () {}
};
// --------------
class Foo2_v2 : virtual public Foo1
{
public:
Foo2_v2 () : Foo1 () {}
};
// --------------
class Foo2 : public Foo1
{
public:
Foo2 () : Foo1 () {}
};
// --------------
class Foo3_m : public Foo2_v1, public Foo2_v2
{
public:
Foo3_m () : Foo1 (), Foo2_v1 (), Foo2_v2 () {}
};
// --------------
class Foo3 : public Foo2
{
public:
Foo3 () : Foo2 () {}
};
// --------------
class Foo4_m : public Foo3_m
{
public:
Foo4_m () : Foo1 (), Foo3_m () {}
};
// --------------
class Foo4 : public Foo3
{
public:
Foo4 () : Foo3 () {}
};
===================== Classes : END =======================
================ Performance tests : BEGIN ================
==================
Creating instances
==================
Summary test results
====================
#----------------------------------------------------------
# Comparison : multiple inheritance vs. single inheritance
#----------------------------------------------------------
# Resource Name : user time used (via rusage)
# Resource Cost Unit : milliseconds (unsigned long long)
# Resource State Unit : timeval
#----------------------------------------------------------
: ---------------------------------------------
: Foo0 : Level-0 base class -> 9
:
: Foo1 : Level-1 single inheritance -> 13
:
: Foo2 : Level-2 single inheritance -> 20
: Foo2_v1 : Level-2 virtual inheritance -> 20
: Foo2_v2 : Level-2 virtual inheritance -> 20
:
: Foo3 : Level-3 single inheritance -> 25
: Foo3_m : Level-3 multiple inheritance -> 42
:
: Foo4 : Level-4 single inheritance -> 32
: Foo4_m : Level-4 multiple inheritance -> 45
: ---------------------------------------------
Raw Log : http://groups.google.com/groups?selm=bglcid%24q2qeg%241%40ID-79865.news.uni-berlin.de
================ Performance tests : END ==================
Regards,
=====================================
Alex Vinokur
mailto:alexvn (AT) connect (DOT) to
http://mathforum.org/library/view/10978.html
=====================================
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|