[Dune] [#564] Use dynamic polymorphism

Dune dune at dune-project.org
Fri Jun 19 17:49:06 CEST 2009


THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

The following task has a new comment added:

FS#564 - Use dynamic polymorphism
User who did this - Oliver Sander (sander)

----------
Last year I did a few experiments about how expensive virtual function calls really are for shape functions.  I'll attach the test program in a second.  Here's what I get with
g++ 4.3.3 and -O

Static
1.95612 sec.
With virtual functions, class allocated on the stack
1.94412 sec.
With virtual functions, class allocated on the heap
2.72017 sec.
With virtual functions, class allocated on the heap, access through the base class
2.70417 sec.
--- function call here ---
static, passed by const reference
1.93612 sec.
dynamic, passed by value
1.94412 sec.
dynamic, passed by const reference
2.86018 sec.
dynamic, passed by pointer the the base class
2.84818 sec.

Please see the code for the precise meaning of these numbers.  The conclusions I draw from them are the following:

- On a very cheap method (evaluate for a q12d element), the overhead is roughly 50%
- If you create a class with virtual functions on the stack and use it right away there
  is no overhead at all
- If you pass a class with virtual functions by value, then there is no overhead either.

You may want to play around with the code a little.  Try larger methods, or different compiler flags.  In particular, it would be interesting to see if you can pass a class
with virtual functions by reference without overhead if the the method you pass it to gets inlined.
----------

More information can be found at the following URL:
http://www.dune-project.org/flyspray/index.php?do=details&task_id=564#comment974

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.




More information about the Dune mailing list