Skip to content

Commit 21dd5cf

Browse files
committed
fixed gcc/clang compile error
1 parent ad7ef7d commit 21dd5cf

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

CxxRTLPerfTestApplication/src/main_bench.cpp

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,51 @@
11

2+
#include <string>
23
#include <benchmark/benchmark.h>
34

4-
#include "TestMirrorProvider.h"
5-
#include "GlobalTestUtils.h"
6-
#include "../../CxxTestProps/inc/Person.h"
7-
#include "../../CxxTestProps/inc/Complex.h"
5+
#include "RTLibInterface.h"
6+
7+
8+
#if defined(_MSC_VER)
9+
# define NOINLINE __declspec(noinline)
10+
#elif defined(__GNUC__)
11+
# define NOINLINE __attribute__((noinline))
12+
#else
13+
# define NOINLINE
14+
#endif
15+
16+
namespace rtl_bench {
17+
18+
static std::optional<std::string> g_msg;
19+
20+
NOINLINE void sendMessage(const char* pMsgStr)
21+
{
22+
g_msg = pMsgStr;
23+
}
24+
25+
const rtl::CxxMirror& cxx_mirror() {
26+
static rtl::CxxMirror m = rtl::CxxMirror({
27+
rtl::type().function("sendMessage").build(sendMessage)
28+
});
29+
return m;
30+
}
31+
}
832

933
// Direct call vs. Reflected call
1034
// ------------------------------------------------------------
1135
static void DirectCall(benchmark::State& state)
1236
{
13-
Person obj;
1437
for (auto _ : state) {
15-
benchmark::DoNotOptimize(complex::getMagnitude());
38+
rtl_bench::sendMessage("direct");
39+
benchmark::ClobberMemory();
1640
}
1741
}
1842

1943
static void ReflectedCall(benchmark::State& state)
2044
{
21-
rtl::Function getMagnitude = test_mirror::cxx().mirror().getFunction(test_utils::str_complex,test_utils::str_getMagnitude).value();
45+
rtl::Function sendMessage = rtl_bench::cxx_mirror().getFunction("sendMessage").value();
2246
for (auto _ : state) {;
23-
benchmark::DoNotOptimize(getMagnitude.bind().call());
47+
sendMessage.bind().call("reflected");
48+
benchmark::ClobberMemory();
2449
}
2550
}
2651

0 commit comments

Comments
 (0)