#include "refl/vertex.h" #include auto cls = &TypeInfo::StaticClass; vec3 v; constexpr int smeta = sizeof(vec3_Meta); constexpr int scls = sizeof(decltype(*cls)); auto ov = cls->New((void*)&v); constexpr Name func = FName("norm"); void TestRefl1(benchmark::State& state) { int x = 1, y = 2; for (auto _ : state) { std::array arr{&x, ov.ptr}; svector svec(&arr.front(), arr.size(), 2); ov.Invoke(FName("norm"), svec); } } BENCHMARK(TestRefl1); void TestRefl2(benchmark::State& state) { int x = 1, y = 2; constexpr auto id = GetStaticFieldID(FName("norm")); auto field = cls->GetField(id); for (auto _ : state) { std::array arr{&x, ov.ptr}; svector svec(&arr.front(), arr.size(), 2); field->Invoke(svec); } } BENCHMARK(TestRefl2); void TestRefl3(benchmark::State& state) { int x = 1, y = 2; constexpr auto id = GetStaticFieldID(FName("norm")); auto field = cls->GetField(id); for (auto _ : state) { field->Invoke({ &x,ov.ptr, x, y }); } } BENCHMARK(TestRefl3); void TestCPlusPlus(benchmark::State& state) { int x = 1, y = 2; for (auto _ : state) { x = v.norm(x, y); } } BENCHMARK(TestCPlusPlus); BENCHMARK_MAIN();