@@ -18,8 +18,10 @@ typedef bool(__fastcall* fnIsTrue)(void* ecx, void* edx);
18
18
typedef const char *(__fastcall* fnHelloWorld)(void * ecx, void * edx);
19
19
20
20
int main () {
21
- RTTI cRTTI1 (true , true , true , true ); // With caching + min iterations
22
- RTTI cRTTI2; // Without caching
21
+ RTTI cRTTI1; // Default
22
+ RTTI cRTTI2 (false , true , true , true ); // With caching
23
+ RTTI cRTTI3 (true ); // With min iterations
24
+ RTTI cRTTI4 (true , true , true , true ); // With cache and min iterations
23
25
24
26
HMODULE hTestDLL = LoadLibrary (TEXT (" TestDLL.dll" ));
25
27
if (!hTestDLL) {
@@ -37,77 +39,154 @@ int main() {
37
39
high_resolution_clock::time_point t1;
38
40
high_resolution_clock::time_point t2;
39
41
40
- for (unsigned char i = 0 ; i < 10 ; i++) {
42
+ // Stage 1
43
+ t1 = high_resolution_clock::now ();
44
+ for (unsigned char i = 0 ; i < 100 ; ++i) {
41
45
if (unTestingRVA != cRTTI1.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
42
46
printf (" Error: Data error!\n " );
43
47
}
44
48
}
45
49
t2 = high_resolution_clock::now ();
46
- printf (" Bench (10 calls) = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
50
+ printf (" Bench (100 calls)............................... = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
47
51
48
52
t1 = high_resolution_clock::now ();
49
- for (unsigned int i = 0 ; i < 10 '000 ; i++ ) {
53
+ for (unsigned short i = 0 ; i < 1 '000 ; ++i ) {
50
54
if (unTestingRVA != cRTTI1.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
51
55
printf (" Error: Data error!\n " );
52
56
}
53
57
}
54
58
t2 = high_resolution_clock::now ();
55
- printf (" Bench (10 000 calls) = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
59
+ printf (" Bench (1 000 calls)............................. = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
56
60
57
61
t1 = high_resolution_clock::now ();
58
- for (unsigned int i = 0 ; i < 500 '000 ; i++ ) {
62
+ for (unsigned int i = 0 ; i < 10 '000 ; ++i ) {
59
63
if (unTestingRVA != cRTTI1.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
60
64
printf (" Error: Data error!\n " );
61
65
}
62
66
}
63
67
t2 = high_resolution_clock::now ();
64
- printf (" Bench (500 000 calls) = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
68
+ printf (" Bench (10 000 calls)............................ = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
65
69
66
70
t1 = high_resolution_clock::now ();
67
- for (unsigned int i = 0 ; i < 1'000 '000 ; i++) {
71
+ for (unsigned int i = 0 ; i < 50 '000 ; i++) {
68
72
if (unTestingRVA != cRTTI1.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
69
73
printf (" Error: Data error!\n " );
70
74
}
71
75
}
72
76
t2 = high_resolution_clock::now ();
73
- printf (" Bench (1 000 000 calls) = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
77
+ printf (" Bench (50 000 calls)............................ = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
74
78
79
+ // Stage 2
75
80
t1 = high_resolution_clock::now ();
76
- for (unsigned char i = 0 ; i < 10 ; i++ ) {
81
+ for (unsigned char i = 0 ; i < 100 ; ++i ) {
77
82
if (unTestingRVA != cRTTI2.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
78
83
printf (" Error: Data error!\n " );
79
84
}
80
85
}
81
86
t2 = high_resolution_clock::now ();
82
- printf (" Bench (10 calls + NoCache + NoMinIterations) = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
87
+ printf (" Bench (100 calls + Cache)....................... = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
83
88
84
89
t1 = high_resolution_clock::now ();
85
- for (unsigned int i = 0 ; i < 10 '000 ; i++ ) {
90
+ for (unsigned short i = 0 ; i < 1 '000 ; ++i ) {
86
91
if (unTestingRVA != cRTTI2.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
87
92
printf (" Error: Data error!\n " );
88
93
}
89
94
}
90
95
t2 = high_resolution_clock::now ();
91
- printf (" Bench (10 000 calls + NoCache + NoMinIterations) = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
96
+ printf (" Bench (1 000 calls + Cache)..................... = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
92
97
93
98
t1 = high_resolution_clock::now ();
94
- for (unsigned int i = 0 ; i < 50 '000 ; i++ ) {
99
+ for (unsigned int i = 0 ; i < 10 '000 ; ++i ) {
95
100
if (unTestingRVA != cRTTI2.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
96
101
printf (" Error: Data error!\n " );
97
102
}
98
103
}
99
104
t2 = high_resolution_clock::now ();
100
- printf (" Bench (50 000 calls + NoCache + NoMinIterations) = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
105
+ printf (" Bench (10 000 calls + Cache).................... = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
101
106
102
107
t1 = high_resolution_clock::now ();
103
- for (unsigned int i = 0 ; i < 100 '000 ; i++) {
108
+ for (unsigned int i = 0 ; i < 50 '000 ; i++) {
104
109
if (unTestingRVA != cRTTI2.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
105
110
printf (" Error: Data error!\n " );
106
111
}
107
112
}
108
113
t2 = high_resolution_clock::now ();
109
- printf (" Bench (100 000 calls + NoCache + NoMinIterations) = %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
114
+ printf (" Bench (50 000 calls + Cache)....................= %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
115
+
116
+ // Stage 3
117
+ t1 = high_resolution_clock::now ();
118
+ for (unsigned char i = 0 ; i < 100 ; ++i) {
119
+ if (unTestingRVA != cRTTI3.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
120
+ printf (" Error: Data error!\n " );
121
+ }
122
+ }
123
+ t2 = high_resolution_clock::now ();
124
+ printf (" Bench (100 calls + MinIterations)...............= %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
125
+
126
+ t1 = high_resolution_clock::now ();
127
+ for (unsigned short i = 0 ; i < 1'000 ; ++i) {
128
+ if (unTestingRVA != cRTTI3.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
129
+ printf (" Error: Data error!\n " );
130
+ }
131
+ }
132
+ t2 = high_resolution_clock::now ();
133
+ printf (" Bench (1 000 calls + MinIterations).............= %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
134
+
135
+ t1 = high_resolution_clock::now ();
136
+ for (unsigned int i = 0 ; i < 10'000 ; ++i) {
137
+ if (unTestingRVA != cRTTI3.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
138
+ printf (" Error: Data error!\n " );
139
+ }
140
+ }
141
+ t2 = high_resolution_clock::now ();
142
+ printf (" Bench (10 000 calls + MinIterations)............= %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
143
+
144
+ t1 = high_resolution_clock::now ();
145
+ for (unsigned int i = 0 ; i < 50'000 ; i++) {
146
+ if (unTestingRVA != cRTTI3.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
147
+ printf (" Error: Data error!\n " );
148
+ }
149
+ }
150
+ t2 = high_resolution_clock::now ();
151
+ printf (" Bench (50 000 calls + MinIterations)............= %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
152
+
153
+ // Stage 4
154
+ t1 = high_resolution_clock::now ();
155
+ for (unsigned char i = 0 ; i < 100 ; ++i) {
156
+ if (unTestingRVA != cRTTI4.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
157
+ printf (" Error: Data error!\n " );
158
+ }
159
+ }
160
+ t2 = high_resolution_clock::now ();
161
+ printf (" Bench (100 calls + Cache + MinIterations).......= %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
162
+
163
+ t1 = high_resolution_clock::now ();
164
+ for (unsigned short i = 0 ; i < 1'000 ; ++i) {
165
+ if (unTestingRVA != cRTTI4.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
166
+ printf (" Error: Data error!\n " );
167
+ }
168
+ }
169
+ t2 = high_resolution_clock::now ();
170
+ printf (" Bench (1 000 calls + Cache + MinIterations).....= %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
110
171
172
+ t1 = high_resolution_clock::now ();
173
+ for (unsigned int i = 0 ; i < 10'000 ; ++i) {
174
+ if (unTestingRVA != cRTTI4.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
175
+ printf (" Error: Data error!\n " );
176
+ }
177
+ }
178
+ t2 = high_resolution_clock::now ();
179
+ printf (" Bench (10 000 calls + Cache + MinIterations)....= %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
180
+
181
+ t1 = high_resolution_clock::now ();
182
+ for (unsigned int i = 0 ; i < 50'000 ; i++) {
183
+ if (unTestingRVA != cRTTI4.GetVTableOffsetFromModule (hTestDLL, " TestingDLL" )) {
184
+ printf (" Error: Data error!\n " );
185
+ }
186
+ }
187
+ t2 = high_resolution_clock::now ();
188
+ printf (" Bench (50 000 calls + Cache + MinIterations)....= %lld ms\n " , duration_cast<std::chrono::milliseconds>(t2 - t1).count ());
189
+
111
190
#endif // BENCHMARK_TEST
112
191
113
192
if (!unTestingRVA) {
0 commit comments