File: ftime-trace-ctfe.d

package info (click to toggle)
ldc 1%3A1.40.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 63,308 kB
  • sloc: cpp: 85,368; ansic: 21,877; makefile: 1,705; sh: 1,018; asm: 584; objc: 135; exp: 48; python: 12
file content (55 lines) | stat: -rw-r--r-- 901 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Test --ftime-trace functionality: CTFE

// RUN: %ldc -c --ftime-trace --ftime-trace-granularity=100 --ftime-trace-file=%t.1 %s && FileCheck %s < %t.1

// CHECK: traceEvents

// CHECK-DAG: CTFE func: mulmul
// CHECK-DAG: CTFE start: Thing
// CHECK-DAG: CTFE func: muloddmul
// CHECK-DAG: ExecuteCompiler

module ftimetrace;

int mulmul(int i) {
    int mul = 666;
    for (; i > 0; i--)
    {
        mul *= i;
    }
    return mul;
}


int times(int mul, int i){
    return mul * i;
}

int muloddmul(int i) {
    int mul = 666;
    for (; i > 0; i--)
    {
        mul = times(mul, i);
    }
    return mul;
}

struct Thing {
    int m;
    this(int i) {
        if (i % 2) {
            m = muloddmul(i);
        } else {
            m = mulmul(i);
        }
    }
}

static immutable Thing thing = Thing(123000);

int foo() {
    auto thing2 = new Thing(123001);
    return 1;
}

enum f = foo();