473,221 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

Multiple inheritance performance hit

Does using multiple inheritance introduce any more performance overhead than
single inheritance?
Jul 19 '05 #1
2 4296
On Wed, 30 Jul 2003 14:32:45 +0100, "Graham Banks"
<gr**********************************@sol-digi.com> wrote:
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
Jul 19 '05 #2

"Graham Banks" <gr**********************************@sol-digi.com> wrote in message news:bg**********@newsg4.svr.pol.co.uk...
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
|
|
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:al****@connect.to
http://mathforum.org/library/view/10978.html
=====================================
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Hung Jung Lu | last post by:
Hi, I think Microsoft did look into Python when they designed C#. (E.g. they got rid of checked exceptions of Java.) However, they followed Java in avoiding multiple inheritance (MI), which is a...
5
by: Morgan Cheng | last post by:
It seems no pattern defined by GoF takes advantage of multiple inheritance. I am wondering if there is a situation where multiple inheritance is a necessary solution. When coding in C++, should...
30
by: Vla | last post by:
why did the designers of c++ think it would be more useful than it turned out to be?
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
47
by: Mark | last post by:
why doesn't .NET support multiple inheritance? I think it's so silly! Cheers, Mark
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
6
by: Joseph Geretz | last post by:
I have the following class which I am serializing and passing back and forth between my Web Service application and the client. public class Token : SoapHeader { public string SID; public...
11
by: John | last post by:
Hi All, Although C# has Generics, it still does not support the generic programming paradigm. Multiple inheritance is required to support real generic programming. Here is a simple design pattern...
0
by: Scott David Daniels | last post by:
Here are some tweaks on both bits of code: Paul McGuire wrote: .... m = for b in bases: if hasattr(b, '__mro__'): if MetaHocObject.ho in b.__mro__: m.append(b) if m:
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.