-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.tin
59 lines (51 loc) · 787 Bytes
/
utils.tin
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
#FUNCTION {max}
{
#IF {%1 > %2}
{
#RETURN %1;
}
{
#RETURN %2;
};
}
#FUNCTION {min}
{
#IF {%1 > %2}
{
#RETURN %2;
}
{
#RETURN %1;
};
}
#FUNCTION {clamp}
{
#IF {%1 > %3}
{
#RETURN %3;
};
#IF {%1 <= %3 && %1 >= %2}
{
#RETURN %1;
}
#RETURN %2;
}
#FUNCTION {has_module}
{
#LOCAL list_check {};
#LIST modules find %1 list_check;
#RETURN $list_check;
}
#FUNCTION {time_start}
{
#FORMAT timers[%1][start] {%U};
#RETURN #NOP;
}
#FUNCTION {time_end}
{
#FORMAT timers[%1][end] {%U};
#MATH timers[%1][elapsed] {($timers[%1][end] - $timers[%1][start]) / 1000.000};
#SHOWME %1: $timers[%1][elapsed]ms;
#UNVAR timers[%1];
#RETURN #NOP;
}