performance of structs vs classes

Steven Schveighoffer schveiguy at yahoo.com
Mon Sep 26 13:34:06 PDT 2011


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

> On 09/26/2011 08:29 PM, Andrej Mitrovic wrote:
>> In the class test reset the timer:
>>      {
>>          auto h = new HClass();
>>          sw.reset(); //<-
>>          sw.start();
>>      }
> thanks a lot ... i totally misused the stopwatch api.
>
> i compiled with:
>    dmd -release -O -inline -m64 -oftarget/dmd/structs_vs_classes  
> experimental/structs_vs_classes.d
> and
>    gdc -O3 -inline -o target/gdc/structs_vs_classes  
> experimental/structs_vs_classes.d
>
> wich resulted in:
> target/dmd/structs_vs_classes
> time with struct: 11326 for 1
> time with class: 11323 for 1
>
> and
> target/gdc/structs_vs_classes
> time with struct: 4011 for 1
> time with class: 6880 for 1

use -frelease to disable invariant calls on gdc.

Very important!

-Steve


More information about the Digitalmars-d-learn mailing list