CTFE Status

Stefan Koch via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 8 13:24:20 PST 2016


I just wanted to post another performance comparision that does 
not test dmd's memory allocator more then anything else :)

[root at localhost dmd]# time src/dmd -c testSettingArrayLength.d  
-bc-ctfe
2147385345u
536821761u
4294639619u

real	0m0.114s
user	0m0.110s
sys	0m0.003s
[root at localhost dmd]# time src/dmd -c testSettingArrayLength.d
2147385345u
536821761u
4294639619u

real	0m0.921s
user	0m0.843s
sys	0m0.077s

Results are obtained running the following code
uint MakeInitAndSumArray(uint length)
{
     uint result;
     uint[] arr;
     arr.length = length;

     while(length--)
     {
         arr[length] = length;
     }
     foreach(e;arr)
     {
       result += e;
     }

     return result;
}

pragma(msg, MakeInitAndSumArray(ushort.max));
pragma(msg, MakeInitAndSumArray(ushort.max/2));
pragma(msg, MakeInitAndSumArray(ushort.max*2));



More information about the Digitalmars-d mailing list