To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 1660
1659  |  1661
Subject: 
Re: C++ OverHead
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Wed, 24 Jan 2001 17:26:35 GMT
Viewed: 
1601 times
  
Hi,

The answer here depends on your coding style.

If you are using non-derived concrete classes, with simple member data and the
default constructor/destructor, then it costs ~10-20 bytes/class.

If you are using non-derived concrete classes, with member data and non-default
constructor/destructor, then the simplest examples seem to add ~50-200
bytes/class.

If you are using derived concrete classes, with no virtual methods, simple
member data, and the default constructor/destructor, it costs ~50 bytes/class.

If you are using virtual methods, it costs ~200 bytes/class + ~12 bytes/virtual
method.

There is additional overhead for each call to a c++ method, since the class
pointer is an additional argument, or ~4 bytes/call additional overhead.  If
you are using inlined functions, this can go away.

The worst case scenario I have seen so far was an implementation of my sensor.H
as an abstract class of sensors, a class for a light sensor, from this abstract
sensor.H.  In this case, the pure C code added ~10 bytes, but the c++ code was
~1 KB.  The current method takes ~40 bytes.  These are very simple classes, so
the overhead is very high!

These numbers a based on gcc-2.95.2 with flags set for optimizing for space.
They also from memory, so take them with a large caveat!

Pat



Message is in Reply To:
  C++ OverHead
 
Hi all, a simple question ( I hope) I'm running a small GA on my rcx block , and I'm fairly happy qwith my results so far, it evolves well tot he conditions, however I'd like to try something new <g>... I'm going to try to evolve sub-sumptive (...) (24 years ago, 23-Jan-01, to lugnet.robotics.rcx.legos)

4 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR