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

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

real    0m0.114s
user    0m0.110s
sys     0m0.003s
[root@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));

Reply via email to