Connecting Tech Pros Worldwide Forums | Help | Site Map

Multiple inheritance performance hit

Graham Banks
Guest
 
Posts: n/a
#1: Jul 19 '05
Does using multiple inheritance introduce any more performance overhead than
single inheritance?



tom_usenet
Guest
 
Posts: n/a
#2: Jul 19 '05

re: Multiple inheritance performance hit


On Wed, 30 Jul 2003 14:32:45 +0100, "Graham Banks"
<grahambanksRemoveIfYouAreNotASpamBot@sol-digi.com> wrote:
[color=blue]
>Does using multiple inheritance introduce any more performance overhead than
>single inheritance?[/color]

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
Alex Vinokur
Guest
 
Posts: n/a
#3: Jul 19 '05

re: Multiple inheritance performance hit



"Graham Banks" <grahambanksRemoveIfYouAreNotASpamBot@sol-digi.com> wrote in message news:bg8hfh$c47$1@newsg4.svr.pol.co.uk...[color=blue]
> Does using multiple inheritance introduce any more performance overhead than
> single inheritance?
>
>[/color]



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
|
|
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....uni-berlin.de

================ Performance tests : END ==================


Regards,
=====================================
Alex Vinokur
mailto:alexvn@connect.to
http://mathforum.org/library/view/10978.html
=====================================


Closed Thread