-
Notifications
You must be signed in to change notification settings - Fork 3
/
performance_timings_dll.cpp
106 lines (84 loc) · 2.42 KB
/
performance_timings_dll.cpp
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
#include "performance_timings.h"
#include <objbase.h>
using namespace cross_compiler_interface;
static const std::string long_string(1024*4,'a');
struct FunctionImp:public implement_interface<TestInterface1>{
FunctionImp(){
f0 = [](){};
f1 = [](){return 10;};
f2 = [](int k){return 10 + k;};
f3 = []()->std::string{
auto s = long_string;
return s;
};
f4 = [](cross_compiler_interface::cr_string s){};
f5 = [](std::string){};
f8 = [](cross_compiler_interface::out<std::string> os){
os.set(long_string);
};
}
};
struct VirtualImp:public VirtualInterface{
virtual void f0(){}
virtual int f1(){return 10;}
virtual int f2(int k){return 10 + k;}
virtual std::string f3(){
auto s = long_string;
return s;
}
virtual void f4(const std::string& s){}
virtual void f5(std::string s){}
virtual const char* f6(std::size_t* pcount){
char* ret = (char*) CoTaskMemAlloc(long_string.size() + 1);
memcpy(ret,long_string.data(),long_string.size());
ret[long_string.size()] = 0;
*pcount = long_string.size();
return ret;
};
virtual void f7(const char*,std::size_t){}
virtual void f8(std::string* os){
*os = long_string;
}
};
struct MemFnImp{
void f0(){}
int f1(){return 10;}
int f2(int k){return 10 + k;}
std::string f3(){
auto s = long_string;
return s;
}
void f4(cross_compiler_interface::cr_string s){}
void f5(std::string){}
void f8(cross_compiler_interface::out<std::string> os){
os.set(long_string);
}
implement_interface<TestInterface1> imp;
MemFnImp(){
imp.f0.set_mem_fn<MemFnImp,&MemFnImp::f0>(this);
imp.f1.set_mem_fn<MemFnImp,&MemFnImp::f1>(this);
imp.f2.set_mem_fn<MemFnImp,&MemFnImp::f2>(this);
imp.f3.set_mem_fn<MemFnImp,&MemFnImp::f3>(this);
imp.f4.set_mem_fn<MemFnImp,&MemFnImp::f4>(this);
imp.f5.set_mem_fn<MemFnImp,&MemFnImp::f5>(this);
imp.f8.set_mem_fn<MemFnImp,&MemFnImp::f8>(this);
}
};
extern "C"{
const portable_base* CROSS_CALL_CALLING_CONVENTION CreateFunctionImpInterface(){
static FunctionImp d_;
return d_.get_portable_base();
}
}
extern "C"{
const portable_base* CROSS_CALL_CALLING_CONVENTION CreateMemFnImpInterface(){
static MemFnImp d_;
return d_.imp.get_portable_base();
}
}
extern "C"{
const portable_base* CROSS_CALL_CALLING_CONVENTION CreateVirtualInterface(){
static VirtualImp d_;
return &d_;
}
}