line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODE: INLINE |
2
|
|
|
|
|
|
|
#include |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
template |
5
|
|
|
|
|
|
|
using function = panda::function; |
6
|
|
|
|
|
|
|
using panda::string_view; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
using vv_fn = function; |
9
|
|
|
|
|
|
|
using vi_fn = function; |
10
|
|
|
|
|
|
|
using iis_fn = function; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
struct Data { |
13
|
|
|
|
|
|
|
Data (int i) : i(i) {} |
14
|
|
|
|
|
|
|
int i; |
15
|
|
|
|
|
|
|
}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
MODULE = MyTest::Typemap PACKAGE = MyTest::Function |
18
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
void s2f_vv (vv_fn fn) { |
21
|
1
|
50
|
|
|
|
|
fn(); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
void s2f_vi (vi_fn fn, int val) { |
25
|
1
|
50
|
|
|
|
|
fn(val); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
void s2f_vi_custom (Sub sub, int val) { |
29
|
4
|
50
|
|
|
|
|
auto fn = xs::sub2function(sub, [](int val) { return Simple(val + 100); }); |
30
|
1
|
50
|
|
|
|
|
fn(val); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
int s2f_iis (Sv sub, int i, string_view d) { |
34
|
2
|
50
|
|
|
|
|
auto fn = xs::sub2function(sub); |
|
|
50
|
|
|
|
|
|
35
|
1
|
50
|
|
|
|
|
RETVAL = fn(i, d); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
int s2f_iis_custom (Sub sub, int i, string_view d) { |
39
|
|
|
|
|
|
|
auto fn = xs::sub2function( |
40
|
|
|
|
|
|
|
sub, |
41
|
2
|
50
|
|
|
|
|
[=](const Sv& sv) { return SvIV(sv) + 10; }, |
42
|
2
|
|
|
|
|
|
[](int val) { return Simple(val + 100); } |
43
|
2
|
50
|
|
|
|
|
); |
44
|
1
|
50
|
|
|
|
|
RETVAL = fn(i, d); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
vi_fn s2f2s_vi (vi_fn fn) { |
48
|
2
|
|
|
|
|
|
RETVAL = fn; |
49
|
1
|
50
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
int s2f_notm (Sub sub, int i) { |
52
|
|
|
|
|
|
|
auto fn = sub2function>( |
53
|
|
|
|
|
|
|
sub, |
54
|
1
|
50
|
|
|
|
|
[=](const Sv& sv) { return Data((int)Simple(sv) + 1); }, |
55
|
2
|
|
|
|
|
|
[] (const Data& data) { return Simple(data.i + 2); } |
56
|
2
|
50
|
|
|
|
|
); |
57
|
1
|
|
|
|
|
|
Data arg(i); |
58
|
1
|
50
|
|
|
|
|
auto ret = fn(arg); |
59
|
1
|
|
|
|
|
|
RETVAL = ret.i; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
uint64_t bench_vv (Sub sub, int cnt) { |
63
|
0
|
|
|
|
|
|
RETVAL = 0; |
64
|
0
|
0
|
|
|
|
|
for (int i = 0; i < cnt; ++i) { |
65
|
0
|
0
|
|
|
|
|
RETVAL += (uint64_t)sub2function(sub).func.get(); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
uint64_t bench_vi (Sub sub, int cnt) { |
70
|
0
|
|
|
|
|
|
RETVAL = 0; |
71
|
0
|
0
|
|
|
|
|
for (int i = 0; i < cnt; ++i) { |
72
|
0
|
0
|
|
|
|
|
RETVAL += (uint64_t)sub2function(sub).func.get(); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
uint64_t bench_iis (Sub sub, int cnt) { |
77
|
0
|
|
|
|
|
|
RETVAL = 0; |
78
|
0
|
0
|
|
|
|
|
for (int i = 0; i < cnt; ++i) { |
79
|
0
|
0
|
|
|
|
|
RETVAL += (uint64_t)sub2function(sub).func.get(); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
uint64_t bench_vvR (int cnt) { |
84
|
0
|
|
|
|
|
|
RETVAL = 0; |
85
|
0
|
0
|
|
|
|
|
vv_fn fn = [](){}; |
86
|
0
|
0
|
|
|
|
|
for (int i = 0; i < cnt; ++i) { |
87
|
0
|
0
|
|
|
|
|
RETVAL += (uint64_t)function2sub(fn).get(); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
uint64_t bench_viR (int cnt) { |
92
|
0
|
|
|
|
|
|
RETVAL = 0; |
93
|
0
|
0
|
|
|
|
|
vi_fn fn = [](int){}; |
94
|
0
|
0
|
|
|
|
|
for (int i = 0; i < cnt; ++i) { |
95
|
0
|
0
|
|
|
|
|
RETVAL += (uint64_t)function2sub(fn).get(); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
uint64_t bench_iisR (int cnt) { |
100
|
0
|
|
|
|
|
|
RETVAL = 0; |
101
|
0
|
0
|
|
|
|
|
iis_fn fn = [](int a, string_view d) -> int { return a + d.length(); }; |
102
|
0
|
0
|
|
|
|
|
for (int i = 0; i < cnt; ++i) { |
103
|
0
|
0
|
|
|
|
|
RETVAL += (uint64_t)function2sub(fn).get(); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |