CTFE Status
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Wed Nov 16 02:07:06 PST 2016
On Wednesday, 16 November 2016 at 09:45:24 UTC, Stefan Koch wrote:
> Here is a small demostration of the performance increase :
>
> [root at localhost dmd]# time src/dmd -c testSettingArrayLength.d
> > x 2> x
>
> real 0m0.199s
> user 0m0.180s
> sys 0m0.017s
> [root at localhost dmd]# time src/dmd -c testSettingArrayLength.d
> -bc-ctfe > x 2> x
>
> real 0m0.072s
> user 0m0.050s
> sys 0m0.020s
>
> Please note that newCTFE only spends 15 ms inside the
> evaluation, most time is spent clearing the 2^^24 Bytes of
> heap-memory to zero.
>
> The sourcode of testSettingArrayLength is
> uint[] MakeAndInitArr(uint length)
> {
> uint[] arr;
> arr.length = length;
>
> foreach(i;0 .. length)
> {
> arr[i] = i + 3;
> }
> return arr;
> }
>
> static assert(MakeAndInitArr(ushort.max).length == ushort.max);
A more accurate breakdown :
Initializing Heap: 18.6 ms
Generating Bytecode: 1.2 ms
Executing Bytecode: 13.2 ms
Converting to CTFE-EXp: 9.1 ms
For a second execution of the same function with the same
arguments within the same file the numbers look like :
Initializing Heap: 16.7 ms
Generating Bytecode: 0.6 ms
Executing Bytecode: 13.2 ms
Converting to CTFE-EXp: 9.3 ms
More information about the Digitalmars-d
mailing list