virtual table, type_info node, type_info function

Discussion in 'C++' started by skscpp, Nov 13, 2003.

  1. skscpp

    skscpp Guest

    I "think" I understand why a virtual table needs to be constructed
    when polymorphic classes are being compiled.

    Now, I also know what a type_info function and type_info node are
    although I am not sure "when" they are constructed by the compiler?

    Also, any books which talks about any of these 3 subjects in detail or
    semi-detail would be nice.

    Thanks.
    skscpp, Nov 13, 2003
    #1
    1. Advertising

  2. skscpp

    Ron Natalie Guest

    "skscpp" <> wrote in message news:...
    > I "think" I understand why a virtual table needs to be constructed
    > when polymorphic classes are being compiled.
    >
    > Now, I also know what a type_info function and type_info node are
    > although I am not sure "when" they are constructed by the compiler?
    >
    > Also, any books which talks about any of these 3 subjects in detail or
    > semi-detail would be nice.


    There is a type_info class and a typeid function. How typeid and virtual
    functions work is an implementation detail. How this works varies form
    compiler to compiler. The important thing for you to know is that adding
    polymorphism to the type adds a tiny space penalty and a virtual call is
    slightly slower than a non-virtual one in most cases.
    Ron Natalie, Nov 13, 2003
    #2
    1. Advertising

  3. skscpp

    Ron Natalie Guest

    "Ron Natalie" <> wrote in message news:3fb41115$0$25282$...

    > There is a type_info class and a typeid function.


    Gak, before someone jumps on me, typeid is an operator NOT a functin.
    Ron Natalie, Nov 13, 2003
    #3
  4. i suppose it is a classical question...

    Ron Natalie wrote:
    > There is a type_info class and a typeid function. How typeid and virtual
    > functions work is an implementation detail. How this works varies form
    > compiler to compiler. The important thing for you to know is that adding
    > polymorphism to the type adds a tiny space penalty and a virtual call is
    > slightly slower than a non-virtual one in most cases.


    i need to perform image analysis and filter application many times per
    second (max 25~30 fps) on images say 800x600x3byte.

    we have three possibilities to operate on every byte:
    1) directly (actual)
    2) function call (intermediate)
    3) virtual function call (nicest)

    of course 1) should be the fastest and 3) the slowest, but would be the
    difference of spent time so different? should i do some benchmarking on
    my own?

    thanks
    domenico

    -----[ Domenico Andreoli, aka cavok
    --[ http://filibusta.crema.unimi.it/~cavok/gpgkey.asc
    ---[ 3A0F 2F80 F79C 678A 8936 4FEE 0677 9033 A20E BC50
    Domenico Andreoli, Nov 13, 2003
    #4
  5. Hi Domenico Andreoli,

    "Domenico Andreoli" <> schrieb im Newsbeitrag
    news:vUUsb.116811$...
    > i need to perform image analysis and filter application many times per
    > second (max 25~30 fps) on images say 800x600x3byte.


    For this kind of application, I'd recommend using assembly language.
    Processors like the Pentium 4 can perform multiple computations per
    instruction and clock cycle (SSE2).
    (refer to the processor documentation available from Intel, at
    http://developer.intel.com/design/pentium4/manuals/, in that case)

    This way, the function call overhead in C++ doesn't matter if you avoid
    calling a method for every pixel by writing the actual analysis or filter
    code in assembly language.

    If that's not feasible for some reason, make sure your methods are terse,
    inlined and avoid object construction in loops with hundreds of thousands of
    iterations.

    I hope that helps.

    Regards,
    Ekkehard Morgenstern.
    Ekkehard Morgenstern, Nov 14, 2003
    #5
  6. EventHelix.com, Nov 14, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,448
  2. sks_cpp

    type_info, vtable

    sks_cpp, Aug 19, 2003, in forum: C++
    Replies:
    54
    Views:
    2,244
    Ron Natalie
    Aug 27, 2003
  3. Bobo

    virtual ~type_info();

    Bobo, Jan 20, 2004, in forum: C++
    Replies:
    3
    Views:
    376
  4. Tjerk Wolterink
    Replies:
    2
    Views:
    1,423
    Dimitre Novatchev
    Aug 24, 2006
  5. =?ISO-8859-1?Q?Erik_Wikstr=F6m?=

    Storing std::type_info

    =?ISO-8859-1?Q?Erik_Wikstr=F6m?=, Aug 11, 2007, in forum: C++
    Replies:
    2
    Views:
    1,618
    Daniel Kraft
    Aug 11, 2007
Loading...

Share This Page