This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[comp.lang.c++] Performance: multiple inheritance vs. single inheritance


"Graham Banks" <grahambanksRemoveIfYouAreNotASpamBot@sol-digi.com> wrote in message news:bg8hfh$c47$1@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=bglcid%24q2qeg%241%40ID-79865.news.uni-berlin.de

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


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





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]