-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtimeit.mdtlbl
More file actions
110 lines (103 loc) · 2.26 KB
/
timeit.mdtlbl
File metadata and controls
110 lines (103 loc) · 2.26 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#**
* 用于快速测试运行时间并打印的工具, 使用标准化时间输出
*#
const TimeIt = (const match @ => *RepeatCount Begin @ {
take*Ipt = @ipt*(sensor $ @this @timescale;);
const Run = (const match @ => F {
take R = $;
R.start = @tick;
take R.Result = F[];
R.dur_ticks = @tick - R.start;
});
const PrintIt = (const match @ => F {
take+I+Sum;
I = 0;
take R = Run[([I &F](__:
do {
setres F[];
} while (*++I) < RepeatCount;
))];
take*Time = floor(R.dur_ticks / RepeatCount * Ipt - (2- 0.5));
print Builtin.Stringify[R->Result]": "Time"lines\n";
setres R.Result;
});
setres PrintIt[Begin];
inline@ F {
PrintIt! F;
}
});
printflush message1;
printflush message1;
TimeIt! (?count:100)
(case1:
_x = "a"+"b";
)
(case2:
_x = (?"a"+"b");
)
(case3:
noop;
noop;
_x = (?"a"+"b");
)
;
printflush message1;
stop;
#* Li >>>
printflush message1
printflush message1
set count 100
sensor __8 @this @timescale
op mul __7 @ipt __8
set __11 0
set __19 @tick
__0_const___16____0:
op add _x "a" "b"
op add __11 __11 1
jump __0_const___16____0 lessThan __11 count
op sub __21 @tick __19
op div __25 __21 count
op mul __24 __25 __7
op sub __23 __24 1.5
op floor __22 __23 0
print "case1"
print ": "
print __22
print "lines\n"
set __30 0
set __38 @tick
__1_const___35____0:
op add __39 "a" "b"
set _x __39
op add __30 __30 1
jump __1_const___35____0 lessThan __30 count
op sub __41 @tick __38
op div __45 __41 count
op mul __44 __45 __7
op sub __43 __44 1.5
op floor __42 __43 0
print "case2"
print ": "
print __42
print "lines\n"
set __50 0
set __58 @tick
__2_const___55____0:
noop
noop
op add __59 "a" "b"
set _x __59
op add __50 __50 1
jump __2_const___55____0 lessThan __50 count
op sub __61 @tick __58
op div __65 __61 count
op mul __64 __65 __7
op sub __63 __64 1.5
op floor __62 __63 0
print "case3"
print ": "
print __62
print "lines\n"
printflush message1
stop
*#