performance of structs vs classes

Christian Köstlin christian.koestlin at gmail.com
Mon Sep 26 12:36:04 PDT 2011


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

which is much better than my wrong measurements...

thanks for the answer!!!

christian


More information about the Digitalmars-d-learn mailing list