performance of structs vs classes

Steven Schveighoffer schveiguy at yahoo.com
Mon Sep 26 11:39:33 PDT 2011


On Mon, 26 Sep 2011 14:14:09 -0400, Christian Köstlin  
<christian.koestlin at gmail.com> wrote:

> I have this small program here, which compares the call-overhead of  
> methods from classes to structs. I guess this always has to be, because  
> of the "polymorphism" of methods of objects.
>
> Is there something I can do to improve on the performance of methods  
> calls with classes?
>
> please see the source here:
> https://gist.github.com/1242911

In addition to Andrej's information (call sw.reset()),  make *sure* you  
compile in -release mode, because in non -release mode, all object methods  
are followed by a call to Object's invariant, which is never inlined!   
However, no invariants are called in release mode.

-Steve


More information about the Digitalmars-d-learn mailing list