virtual table, type_info node, type_info function

S

skscpp

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.
 
R

Ron Natalie

skscpp said:
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.
 
D

Domenico Andreoli

i suppose it is a classical question...

Ron said:
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
 
E

Ekkehard Morgenstern

Hi Domenico Andreoli,

Domenico Andreoli said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,037
Latest member
MozzGuardBugs

Latest Threads

Top