523 lines
23 KiB
C++
523 lines
23 KiB
C++
#pragma once
|
|
|
|
#include "Engine/Scripting/Script.h"
|
|
#include <Engine/Animations/Curve.h>
|
|
#include <Engine/AI/Behavior.h>
|
|
|
|
#include "Engine/Graphics/PostProcessEffect.h"
|
|
#include "Engine/Graphics/RenderTask.h"
|
|
#include "Engine/Graphics/Graphics.h"
|
|
#include "Engine/Scripting/SoftTypeReference.h"
|
|
#include "Engine/Content/SceneReference.h"
|
|
#include "Engine/Content/Assets/Model.h"
|
|
#include "Engine/Networking/NetworkChannelType.h"
|
|
#include "Engine/Online/IOnlinePlatform.h"
|
|
#include "Engine/Render2D/FontAsset.h"
|
|
|
|
API_STRUCT(NoDefault) struct StringStruct : public ISerializable
|
|
{
|
|
API_AUTO_SERIALIZATION();
|
|
DECLARE_SCRIPTING_TYPE_MINIMAL(StringStruct);
|
|
|
|
API_FIELD() String StringContent = TEXT("test");
|
|
API_FIELD() String StringEmpty = TEXT("");
|
|
API_FIELD() String StringEmpty2 = String::Empty;
|
|
API_FIELD() String StringNull = nullptr;
|
|
};
|
|
|
|
API_STRUCT(NoDefault) struct TestStruct : public ISerializable
|
|
{
|
|
API_AUTO_SERIALIZATION();
|
|
DECLARE_SCRIPTING_TYPE_MINIMAL(TestStruct);
|
|
|
|
// Var
|
|
API_FIELD() Float3 Vector = Float3::One;
|
|
// Ref
|
|
API_FIELD() ScriptingObject* Object = nullptr;
|
|
// Soft Type Ref
|
|
API_FIELD() SoftTypeReference<ScriptingObject> SoftTypeRef;
|
|
// Scene Ref
|
|
API_FIELD() SceneReference SceneRef;
|
|
|
|
friend bool operator==(const TestStruct& lhs, const TestStruct& rhs)
|
|
{
|
|
return lhs.Vector == rhs.Vector &&
|
|
lhs.Object == rhs.Object &&
|
|
lhs.SoftTypeRef == rhs.SoftTypeRef &&
|
|
lhs.SceneRef == rhs.SceneRef;
|
|
}
|
|
};
|
|
|
|
API_CLASS() class GAME_API MyScript2 : public Script
|
|
{
|
|
API_AUTO_SERIALIZATION();
|
|
DECLARE_SCRIPTING_TYPE(MyScript2);
|
|
|
|
API_FUNCTION() virtual void GetStats(API_PARAM(Ref) int64& allocations, API_PARAM(Ref) int64& deallocations) {};
|
|
|
|
API_FUNCTION() virtual void ManagedCoverageTests() {};
|
|
API_FUNCTION() virtual void CoverageTest1(int32 intParam, bool boolParam, Actor* actorParam, String& stringRefParam, StringAnsi& stringAnsiRefParam, Float3 float3Param) {};
|
|
API_FUNCTION() virtual void CoverageTest1Array(Array<int32> intArrayParam, Array<bool> boolArrayParam, Array<Actor*> actorArrayParam, Array<String> stringArrayParam, Array<StringAnsi> stringAnsiArrayParam, Array<Float3> float3ArrayParam) {};
|
|
API_FUNCTION() virtual void CoverageTest1ByRef(API_PARAM(Ref) int32& intRefParam, API_PARAM(Ref) bool& boolRefParam, API_PARAM(Ref) String& stringRefParam, API_PARAM(Ref) StringAnsi& stringAnsiRefParam, API_PARAM(Ref) Float3& float3RefParam) {};
|
|
#if false
|
|
//APIa_FUNCTION() virtual void CoverageTest1ArrayByRef(API_PARAM(Ref) Array<int32>& intArrayRefParam, API_PARAM(Ref) Array<bool>& boolArrayRefParam, API_PARAM(Ref) Array<String>& stringArrayRefParam, API_PARAM(Ref) Array<StringAnsi>& stringAnsiArrayRefParam, API_PARAM(Ref) Array<Float3>& float3ArrayRefParam) {};
|
|
#endif
|
|
API_FUNCTION() virtual void CoverageTest2(Guid guidParam, AssetReference<FontAsset> fontAssetReferenceParam, Array<Guid> guidArrayParam, Array<AssetReference<FontAsset>> fontAssetReferenceArrayParam) {};
|
|
API_FUNCTION() virtual void CoverageTest3(ModelLOD* modelLodParam, API_PARAM(Out) Array<ModelLOD*>& modelLodArrayParam) {};
|
|
#if false
|
|
//APIa_FUNCTION() virtual void CoverageTest4(BytesContainer bytesContainerParam, API_PARAM(Out) BytesContainer& bytesContainerOutParam) {};
|
|
#endif
|
|
API_FUNCTION() virtual void CoverageNamespaces1(NetworkChannelType a, Array<NetworkChannelType> b, OnlineLeaderboardSortModes c, Array<OnlineLeaderboardSortModes> d, OnlineLeaderboardValueFormats e, Array<OnlineLeaderboardValueFormats> f) {};
|
|
|
|
API_FUNCTION() virtual void SimpleCall() { ASSERT(false); };
|
|
API_FUNCTION() virtual void SimpleParams(int32 intParam, float boolParam, char charParam, double doubleParam, int64 int64Param) {};
|
|
API_FUNCTION() virtual void StringParamAnsi(StringAnsi str) {};
|
|
API_FUNCTION() virtual void StringParam(String str) {};
|
|
#if false
|
|
//API_FUNCTION() virtual void StringParamRef(String& str) {};
|
|
#endif
|
|
API_FUNCTION() virtual void StringParamRefConst(const String& str) {};
|
|
API_FUNCTION() virtual void StringParamAsRef(API_PARAM(Ref) String& stringRefParam) {};
|
|
API_FUNCTION() virtual void ActorParam(Actor* actorParam) {};
|
|
API_FUNCTION() virtual void ComplexParam(BehaviorUpdateContext context) {};
|
|
API_FUNCTION() virtual void Complex2Param(RenderContext& context) {};
|
|
API_FUNCTION() virtual void Complex2ParamConst(const RenderContext& context) {};
|
|
API_FUNCTION() virtual void Complex2ParamAsRef(API_PARAM(Ref) RenderContext& context) {};
|
|
API_FUNCTION() virtual void SimpleArrayParam(Array<int> intArrayParam) {};
|
|
API_FUNCTION() virtual void SimpleArrayParamRef(Array<int>& intArrayParam) {};
|
|
API_FUNCTION() virtual void SimpleArrayParamRefConst(const Array<int>& intArrayParam) {};
|
|
API_FUNCTION() virtual void SimpleArrayParamAsRef(API_PARAM(Ref) Array<int>& intArrayRefParam) {};
|
|
API_FUNCTION() virtual void ActorArrayParam(Array<Actor*> actorArrayParam) {};
|
|
API_FUNCTION() virtual void ActorArrayParamRef(Array<Actor*>& actorArrayParam) {};
|
|
API_FUNCTION() virtual void ActorArrayParamRefConst(const Array<Actor*>& actorArrayParam) {};
|
|
|
|
#if false
|
|
//API_FUN_CTION() virtual void ActorArrayParamAsRef(API_PARAM(Ref) Array<Actor*>& arr) {};
|
|
#endif
|
|
|
|
API_FUNCTION() virtual void StringFieldStructParam(StringStruct& stringStruct) { ASSERT(false); };
|
|
API_FUNCTION() virtual void StringFieldStructParamAsRef(API_PARAM(Ref) StringStruct& stringStruct) { ASSERT(false); };
|
|
API_FUNCTION() virtual void StringFieldStructArrayParam(Array<StringStruct>& stringStructArray) { ASSERT(false); };
|
|
API_FUNCTION() virtual void StringFieldStructArrayParamAsRef(API_PARAM(Ref) Array<StringStruct>& stringStructArray) { ASSERT(false); };
|
|
|
|
API_FUNCTION() virtual void ComplexArrayParam(Array<TestStruct> arrayParam) {};
|
|
API_FUNCTION() virtual void ComplexArrayParamRef(Array<TestStruct>& arrayParam) {};
|
|
API_FUNCTION() virtual void ComplexArrayParamRefConst(const Array<TestStruct>& arrayParam) {};
|
|
API_FUNCTION() virtual void ComplexArrayParamAsRef(API_PARAM(Ref) Array<TestStruct>& arrayRefParam) {};
|
|
|
|
|
|
//API_EVENT() Delegate<int32, Float3, const String&, String&, TestStruct&, const Array<TestStruct>&, Array<TestStruct>&> TestEvent;
|
|
|
|
};
|
|
|
|
struct BenchmarkContext
|
|
{
|
|
MyScript2* scriptTwo;
|
|
Array<uint64> results;
|
|
};
|
|
|
|
API_CLASS() class GAME_API MyScript : public Script
|
|
{
|
|
API_AUTO_SERIALIZATION();
|
|
DECLARE_SCRIPTING_TYPE(MyScript);
|
|
|
|
/*API_STRUCT() struct GAME_API InnerStructer
|
|
{
|
|
public:
|
|
float floaty;
|
|
};*/
|
|
|
|
//API_FIELD() MyThinger<int> thingey;
|
|
|
|
template<typename... TArgs>
|
|
void BenchmarkCall(BenchmarkContext& context, void(MyScript2::* fun)(TArgs...),
|
|
TArgs...);
|
|
|
|
//void BenchmarkCall(int times, BenchmarkContext& context, void(MyScript2::*fun)());
|
|
|
|
|
|
|
|
// [Script]
|
|
void OnStart() override;
|
|
void OnEnable() override;
|
|
void OnDisable() override;
|
|
void OnUpdate() override;
|
|
|
|
API_FUNCTION() virtual void ManagedCoverageTests() {};
|
|
API_FUNCTION() virtual void CoverageTest1(int32 a, bool b, Actor* c, String& d, StringAnsi& e, Float3 f) {};
|
|
API_FUNCTION() virtual void CoverageTest1Array(Array<int32> a, Array<bool> b, Array<Actor*> c, Array<String> d, Array<StringAnsi> e, Array<Float3> f) {};
|
|
API_FUNCTION() virtual void CoverageTest1ByRef(API_PARAM(Ref) int32& a, API_PARAM(Ref) bool& b, API_PARAM(Ref) String& d, API_PARAM(Ref) StringAnsi& e, API_PARAM(Ref) Float3& f) {};
|
|
#if false
|
|
//APIa_FUNCTION() virtual void CoverageTest1ArrayByRef(API_PARAM(Ref) Array<int32>& a, API_PARAM(Ref) Array<bool>& b, API_PARAM(Ref) Array<String>& d, API_PARAM(Ref) Array<StringAnsi>& e, API_PARAM(Ref) Array<Float3>& f) {};
|
|
#endif
|
|
API_FUNCTION() virtual void CoverageTest2(Guid a, AssetReference<FontAsset> b, Array<Guid> c, Array<AssetReference<FontAsset>> d) {};
|
|
API_FUNCTION() virtual void CoverageTest3(ModelLOD* a, API_PARAM(Out) Array<ModelLOD*>& c) {};
|
|
#if false
|
|
//APIa_FUNCTION() virtual void CoverageTest4(BytesContainer a, API_PARAM(Out) BytesContainer& b) {};
|
|
#endif
|
|
API_FUNCTION() virtual void CoverageNamespaces1(NetworkChannelType a, Array<NetworkChannelType> b, OnlineLeaderboardSortModes c, Array<OnlineLeaderboardSortModes> d, OnlineLeaderboardValueFormats e, Array<OnlineLeaderboardValueFormats> f) {};
|
|
|
|
|
|
//API_FUNCTION() void Test1(API_PARAM(REF) Array<TestTypeEnum>& eenums) {};
|
|
//API_FUNCTION() BezierCurve<Transform>.Keyframe Test2(BezierCurve<Transform> kef) {};
|
|
};
|
|
|
|
#define LOG_TEST(FUNC) \
|
|
if (thunkTests || invokeTests || callTests) LOG(Info, #FUNC);
|
|
|
|
#define BENCHMARK_INVOKE_ARGS0(REPEAT, FUNC) \
|
|
{ \
|
|
auto klass = MyScript2::GetStaticClass(); \
|
|
auto method = klass->GetMethod(#FUNC, 0); \
|
|
auto instance = scriptTwo->GetManagedInstance(); \
|
|
MObject* exception = nullptr; \
|
|
const auto times = REPEAT; \
|
|
const auto chunkTimes = CHUNK_TIMES; \
|
|
const auto freq = Platform::GetClockFrequency(); \
|
|
results.Clear(); \
|
|
auto start2 = Platform::GetTimeCycles(); \
|
|
for (int i = 0; i < times; ++i) \
|
|
{ \
|
|
auto start = Platform::GetTimeCycles(); \
|
|
for (int j = 0; j < chunkTimes; ++j) \
|
|
method->Invoke(instance, nullptr, &exception); \
|
|
auto end = Platform::GetTimeCycles(); \
|
|
auto elapsed = end - start; \
|
|
results.Add(elapsed); \
|
|
} \
|
|
auto end2 = Platform::GetTimeCycles(); \
|
|
auto elapsed2 = end2 - start2; \
|
|
Sorting::MergeSort(results); \
|
|
const auto resultsIndex = 0; \
|
|
LOG(Info, " - InvokeOnly: {:.1f}ns ({:.0f}ms total {} times)", (results[resultsIndex] * (1.0 / static_cast<double>(freq)) * 1000000000 / chunkTimes), (elapsed2 * (1.0 / static_cast<double>(freq)) * 1000), times*chunkTimes); \
|
|
}
|
|
#define BENCHMARK_INVOKE_ARGS1(REPEAT, FUNC, PARAM1) \
|
|
void* params[1]; \
|
|
{ \
|
|
auto klass = MyScript2::GetStaticClass(); \
|
|
auto method = klass->GetMethod(#FUNC, 1); \
|
|
auto instance = scriptTwo->GetManagedInstance(); \
|
|
MObject* exception = nullptr; \
|
|
const auto times = REPEAT; \
|
|
const auto chunkTimes = CHUNK_TIMES; \
|
|
const auto freq = Platform::GetClockFrequency(); \
|
|
params[0] = PARAM1; \
|
|
results.Clear(); \
|
|
auto start2 = Platform::GetTimeCycles(); \
|
|
for (int i = 0; i < times; ++i) \
|
|
{ \
|
|
auto start = Platform::GetTimeCycles(); \
|
|
for (int j = 0; j < chunkTimes; ++j) \
|
|
method->Invoke(instance, params, &exception); \
|
|
auto end = Platform::GetTimeCycles(); \
|
|
auto elapsed = end - start; \
|
|
results.Add(elapsed); \
|
|
} \
|
|
auto end2 = Platform::GetTimeCycles(); \
|
|
auto elapsed2 = end2 - start2; \
|
|
Sorting::MergeSort(results); \
|
|
const auto resultsIndex = 0; \
|
|
LOG(Info, " - InvokeOnly: {:.1f}ns ({:.0f}ms total {} times)", (results[resultsIndex] * (1.0 / static_cast<double>(freq)) * 1000000000 / chunkTimes), (elapsed2 * (1.0 / static_cast<double>(freq)) * 1000), times*chunkTimes); \
|
|
}
|
|
#define BENCHMARK_INVOKE_ARGS1_REF(REPEAT, FUNC, PARAM1, PARAM1_CLEAN) \
|
|
{ \
|
|
auto const NUM_PARAMS = 1; \
|
|
auto klass = MyScript2::GetStaticClass(); \
|
|
auto method = klass->GetMethod(#FUNC, NUM_PARAMS); \
|
|
auto instance = scriptTwo->GetManagedInstance(); \
|
|
MObject* exception = nullptr; \
|
|
const auto times = REPEAT; \
|
|
const auto chunkTimes = CHUNK_TIMES; \
|
|
const auto freq = Platform::GetClockFrequency(); \
|
|
void* params[NUM_PARAMS]; \
|
|
params[0] = PARAM1; \
|
|
results.Clear(); \
|
|
auto start2 = Platform::GetTimeCycles(); \
|
|
for (int i = 0; i < times; ++i) \
|
|
{ \
|
|
void* params_call[CHUNK_TIMES * NUM_PARAMS]; \
|
|
void* params_call_orig[CHUNK_TIMES * NUM_PARAMS]; \
|
|
for (int j = 0; j < chunkTimes * NUM_PARAMS; j += NUM_PARAMS) \
|
|
{ \
|
|
params_call_orig[j+0] = params[0]; \
|
|
params_call[j+0] = ¶ms_call_orig[j+0]; \
|
|
} \
|
|
auto start = Platform::GetTimeCycles(); \
|
|
for (int j = 0; j < chunkTimes; ++j) \
|
|
{ \
|
|
method->Invoke(instance, ¶ms_call[j * NUM_PARAMS], &exception); \
|
|
} \
|
|
auto end = Platform::GetTimeCycles(); \
|
|
auto elapsed = end - start; \
|
|
results.Add(elapsed); \
|
|
for (int j = 0; j < chunkTimes * NUM_PARAMS; j += NUM_PARAMS) \
|
|
{ \
|
|
if (params_call_orig[j+0] != params[0]) \
|
|
{ \
|
|
void* param = params_call_orig[j+0]; \
|
|
PARAM1_CLEAN((MObject*)param); \
|
|
} \
|
|
} \
|
|
} \
|
|
auto end2 = Platform::GetTimeCycles(); \
|
|
auto elapsed2 = end2 - start2; \
|
|
Sorting::MergeSort(results); \
|
|
{ \
|
|
void* param = params[0]; \
|
|
PARAM1_CLEAN((MObject*)param); \
|
|
} \
|
|
const auto resultsIndex = 0; \
|
|
LOG(Info, " - InvokeOnly: {:.1f}ns ({:.0f}ms total {} times)", (results[resultsIndex] * (1.0 / static_cast<double>(freq)) * 1000000000 / chunkTimes), (elapsed2 * (1.0 / static_cast<double>(freq)) * 1000), times*chunkTimes); \
|
|
}
|
|
#define BENCHMARK_INVOKE_ARGS2(REPEAT, FUNC, PARAM1, PARAM2) \
|
|
void* params[2]; \
|
|
{ \
|
|
auto klass = MyScript2::GetStaticClass(); \
|
|
auto method = klass->GetMethod(#FUNC, 2); \
|
|
auto instance = scriptTwo->GetManagedInstance(); \
|
|
MObject* exception = nullptr; \
|
|
const auto times = REPEAT; \
|
|
const auto chunkTimes = CHUNK_TIMES; \
|
|
const auto freq = Platform::GetClockFrequency(); \
|
|
params[0] = PARAM1; \
|
|
params[1] = PARAM2; \
|
|
results.Clear(); \
|
|
auto start2 = Platform::GetTimeCycles(); \
|
|
for (int i = 0; i < times; ++i) \
|
|
{ \
|
|
auto start = Platform::GetTimeCycles(); \
|
|
for (int j = 0; j < chunkTimes; ++j) \
|
|
method->Invoke(instance, params, &exception); \
|
|
auto end = Platform::GetTimeCycles(); \
|
|
auto elapsed = end - start; \
|
|
results.Add(elapsed); \
|
|
} \
|
|
auto end2 = Platform::GetTimeCycles(); \
|
|
auto elapsed2 = end2 - start2; \
|
|
Sorting::MergeSort(results); \
|
|
const auto resultsIndex = 0; \
|
|
LOG(Info, " - InvokeOnly: {:.1f}ns ({:.0f}ms total {} times)", (results[resultsIndex] * (1.0 / static_cast<double>(freq)) * 1000000000 / chunkTimes), (elapsed2 * (1.0 / static_cast<double>(freq)) * 1000), times*chunkTimes); \
|
|
}
|
|
#define BENCHMARK_INVOKE_ARGS3(REPEAT, FUNC, PARAM1, PARAM2, PARAM3) \
|
|
void* params[3]; \
|
|
{ \
|
|
auto klass = MyScript2::GetStaticClass(); \
|
|
auto method = klass->GetMethod(#FUNC, 3); \
|
|
auto instance = scriptTwo->GetManagedInstance(); \
|
|
MObject* exception = nullptr; \
|
|
const auto times = REPEAT; \
|
|
const auto chunkTimes = CHUNK_TIMES; \
|
|
const auto freq = Platform::GetClockFrequency(); \
|
|
params[0] = PARAM1; \
|
|
params[1] = PARAM2; \
|
|
params[2] = PARAM3; \
|
|
results.Clear(); \
|
|
auto start2 = Platform::GetTimeCycles(); \
|
|
for (int i = 0; i < times; ++i) \
|
|
{ \
|
|
auto start = Platform::GetTimeCycles(); \
|
|
for (int j = 0; j < chunkTimes; ++j) \
|
|
method->Invoke(instance, params, &exception); \
|
|
auto end = Platform::GetTimeCycles(); \
|
|
auto elapsed = end - start; \
|
|
results.Add(elapsed); \
|
|
} \
|
|
auto end2 = Platform::GetTimeCycles(); \
|
|
auto elapsed2 = end2 - start2; \
|
|
Sorting::MergeSort(results); \
|
|
const auto resultsIndex = 0; \
|
|
LOG(Info, " - InvokeOnly: {:.1f}ns ({:.0f}ms total {} times)", (results[resultsIndex] * (1.0 / static_cast<double>(freq)) * 1000000000 / chunkTimes), (elapsed2 * (1.0 / static_cast<double>(freq)) * 1000), times*chunkTimes); \
|
|
}
|
|
#define BENCHMARK_INVOKE_ARGS4(REPEAT, FUNC, PARAM1, PARAM2, PARAM3, PARAM4) \
|
|
void* params[4]; \
|
|
{ \
|
|
auto klass = MyScript2::GetStaticClass(); \
|
|
auto method = klass->GetMethod(#FUNC, 4); \
|
|
auto instance = scriptTwo->GetManagedInstance(); \
|
|
MObject* exception = nullptr; \
|
|
const auto times = REPEAT; \
|
|
const auto chunkTimes = CHUNK_TIMES; \
|
|
const auto freq = Platform::GetClockFrequency(); \
|
|
params[0] = PARAM1; \
|
|
params[1] = PARAM2; \
|
|
params[2] = PARAM3; \
|
|
params[3] = PARAM4; \
|
|
results.Clear(); \
|
|
auto start2 = Platform::GetTimeCycles(); \
|
|
for (int i = 0; i < times; ++i) \
|
|
{ \
|
|
auto start = Platform::GetTimeCycles(); \
|
|
for (int j = 0; j < chunkTimes; ++j) \
|
|
method->Invoke(instance, params, &exception); \
|
|
auto end = Platform::GetTimeCycles(); \
|
|
auto elapsed = end - start; \
|
|
results.Add(elapsed); \
|
|
} \
|
|
auto end2 = Platform::GetTimeCycles(); \
|
|
auto elapsed2 = end2 - start2; \
|
|
Sorting::MergeSort(results); \
|
|
const auto resultsIndex = 0; \
|
|
LOG(Info, " - InvokeOnly: {:.1f}ns ({:.0f}ms total {} times)", (results[resultsIndex] * (1.0 / static_cast<double>(freq)) * 1000000000 / chunkTimes), (elapsed2 * (1.0 / static_cast<double>(freq)) * 1000), times*chunkTimes); \
|
|
}
|
|
#define BENCHMARK_INVOKE_ARGS5(REPEAT, FUNC, PARAM1, PARAM2, PARAM3, PARAM4, PARAM5) \
|
|
void* params[5]; \
|
|
{ \
|
|
auto klass = MyScript2::GetStaticClass(); \
|
|
auto method = klass->GetMethod(#FUNC, 5); \
|
|
auto instance = scriptTwo->GetManagedInstance(); \
|
|
MObject* exception = nullptr; \
|
|
const auto times = REPEAT; \
|
|
const auto chunkTimes = CHUNK_TIMES; \
|
|
const auto freq = Platform::GetClockFrequency(); \
|
|
params[0] = PARAM1; \
|
|
params[1] = PARAM2; \
|
|
params[2] = PARAM3; \
|
|
params[3] = PARAM4; \
|
|
params[4] = PARAM5; \
|
|
results.Clear(); \
|
|
auto start2 = Platform::GetTimeCycles(); \
|
|
for (int i = 0; i < times; ++i) \
|
|
{ \
|
|
auto start = Platform::GetTimeCycles(); \
|
|
for (int j = 0; j < chunkTimes; ++j) \
|
|
method->Invoke(instance, params, &exception); \
|
|
auto end = Platform::GetTimeCycles(); \
|
|
auto elapsed = end - start; \
|
|
results.Add(elapsed); \
|
|
} \
|
|
auto end2 = Platform::GetTimeCycles(); \
|
|
auto elapsed2 = end2 - start2; \
|
|
Sorting::MergeSort(results); \
|
|
const auto resultsIndex = 0; \
|
|
LOG(Info, " - InvokeOnly: {:.1f}ns ({:.0f}ms total {} times)", (results[resultsIndex] * (1.0 / static_cast<double>(freq)) * 1000000000 / chunkTimes), (elapsed2 * (1.0 / static_cast<double>(freq)) * 1000), times*chunkTimes); \
|
|
}
|
|
|
|
#define BENCHMARK_THUNK_BEGIN_ARGS0(REPEAT, FUNC) \
|
|
{ \
|
|
const auto times = REPEAT; \
|
|
const auto chunkTimes = CHUNK_TIMES; \
|
|
typedef void (*Thunk)(void* instance, MObject** exception); \
|
|
const auto thunk = (Thunk)scriptTwo->GetClass()->GetMethod(#FUNC, 0)->GetThunk(); \
|
|
const auto instance = scriptTwo->GetOrCreateManagedInstance(); \
|
|
MObject* exception = nullptr;
|
|
#define BENCHMARK_THUNK_CALL_ARGS0() \
|
|
const auto freq = Platform::GetClockFrequency(); \
|
|
results.Clear(); \
|
|
auto start2 = Platform::GetTimeCycles(); \
|
|
for (int i = 0; i < times; ++i) \
|
|
{ \
|
|
auto start = Platform::GetTimeCycles(); \
|
|
for (int j = 0; j < chunkTimes; ++j) \
|
|
thunk(instance, &exception); \
|
|
auto end = Platform::GetTimeCycles(); \
|
|
auto elapsed = end - start; \
|
|
results.Add(elapsed); \
|
|
} \
|
|
auto end2 = Platform::GetTimeCycles(); \
|
|
auto elapsed2 = end2 - start2; \
|
|
Sorting::MergeSort(results); \
|
|
const auto resultsIndex = 0; \
|
|
LOG(Info, " - InvokeThunkOnly: {:.1f}ns ({:.0f}ms total {} times)", (results[resultsIndex] * (1.0 / static_cast<double>(freq)) * 1000000000 / chunkTimes), (elapsed2 * (1.0 / static_cast<double>(freq)) * 1000), times*chunkTimes);
|
|
#define BENCHMARK_THUNK_BEGIN_ARGS1(REPEAT, FUNC) \
|
|
{ \
|
|
const auto times = REPEAT; \
|
|
const auto chunkTimes = CHUNK_TIMES; \
|
|
typedef void (*Thunk)(void* instance, void*, MObject** exception); \
|
|
const auto thunk = (Thunk)scriptTwo->GetClass()->GetMethod(#FUNC, 1)->GetThunk(); \
|
|
const auto instance = scriptTwo->GetOrCreateManagedInstance(); \
|
|
MObject* exception = nullptr; \
|
|
void* params[1];
|
|
#define BENCHMARK_THUNK_CALL_ARGS1() \
|
|
const auto freq = Platform::GetClockFrequency(); \
|
|
results.Clear(); \
|
|
auto start2 = Platform::GetTimeCycles(); \
|
|
for (int i = 0; i < times; ++i) \
|
|
{ \
|
|
auto start = Platform::GetTimeCycles(); \
|
|
for (int j = 0; j < chunkTimes; ++j) \
|
|
thunk(instance, params[0], &exception); \
|
|
auto end = Platform::GetTimeCycles(); \
|
|
auto elapsed = end - start; \
|
|
results.Add(elapsed); \
|
|
} \
|
|
auto end2 = Platform::GetTimeCycles(); \
|
|
auto elapsed2 = end2 - start2; \
|
|
Sorting::MergeSort(results); \
|
|
const auto resultsIndex = 0; \
|
|
LOG(Info, " - InvokeThunkOnly: {:.1f}ns ({:.0f}ms total {} times)", (results[resultsIndex] * (1.0 / static_cast<double>(freq)) * 1000000000 / chunkTimes), (elapsed2 * (1.0 / static_cast<double>(freq)) * 1000), times*chunkTimes);
|
|
#define BENCHMARK_THUNK_CALL_ARGS1_REF(FUN) \
|
|
const auto freq = Platform::GetClockFrequency(); \
|
|
results.Clear(); \
|
|
auto start2 = Platform::GetTimeCycles(); \
|
|
for (int i = 0; i < times; ++i) \
|
|
{ \
|
|
auto start = Platform::GetTimeCycles(); \
|
|
for (int j = 0; j < chunkTimes; ++j) \
|
|
{ \
|
|
thunk(instance, params[0], &exception); \
|
|
FUN \
|
|
} \
|
|
auto end = Platform::GetTimeCycles(); \
|
|
auto elapsed = end - start; \
|
|
results.Add(elapsed); \
|
|
} \
|
|
auto end2 = Platform::GetTimeCycles(); \
|
|
auto elapsed2 = end2 - start2; \
|
|
Sorting::MergeSort(results); \
|
|
const auto resultsIndex = 0; \
|
|
LOG(Info, " - InvokeThunkOnly: {:.1f}ns ({:.0f}ms total {} times)", (results[resultsIndex] * (1.0 / static_cast<double>(freq)) * 1000000000 / chunkTimes), (elapsed2 * (1.0 / static_cast<double>(freq)) * 1000), times*chunkTimes);
|
|
#define BENCHMARK_THUNK_BEGIN_ARGS5(REPEAT, FUNC) \
|
|
{ \
|
|
const auto times = REPEAT; \
|
|
const auto chunkTimes = CHUNK_TIMES; \
|
|
typedef void (*Thunk)(void* instance, void*, void*, void*, void*, void*, MObject** exception); \
|
|
const auto thunk = (Thunk)scriptTwo->GetClass()->GetMethod(#FUNC, 5)->GetThunk(); \
|
|
const auto instance = scriptTwo->GetOrCreateManagedInstance(); \
|
|
MObject* exception = nullptr; \
|
|
void* params[5];
|
|
#define BENCHMARK_THUNK_CALL_ARGS5() \
|
|
const auto freq = Platform::GetClockFrequency(); \
|
|
results.Clear(); \
|
|
auto start2 = Platform::GetTimeCycles(); \
|
|
for (int i = 0; i < times; ++i) \
|
|
{ \
|
|
auto start = Platform::GetTimeCycles(); \
|
|
for (int j = 0; j < chunkTimes; ++j) \
|
|
thunk(instance, params[0], params[1], params[2], params[3], params[4], &exception); \
|
|
auto end = Platform::GetTimeCycles(); \
|
|
auto elapsed = end - start; \
|
|
results.Add(elapsed); \
|
|
} \
|
|
auto end2 = Platform::GetTimeCycles(); \
|
|
auto elapsed2 = end2 - start2; \
|
|
Sorting::MergeSort(results); \
|
|
const auto resultsIndex = 0; \
|
|
LOG(Info, " - InvokeThunkOnly: {:.1f}ns ({:.0f}ms total {} times)", (results[resultsIndex] * (1.0 / static_cast<double>(freq)) * 1000000000 / chunkTimes), (elapsed2 * (1.0 / static_cast<double>(freq)) * 1000), times*chunkTimes);
|
|
#define BENCHMARK_THUNK_END() \
|
|
}
|
|
#define COVERAGE_CALL_ARGS2(FUNC, PARAM1, PARAM2) \
|
|
{ \
|
|
LOG(Info, #FUNC); \
|
|
scriptTwo->FUNC(PARAM1, PARAM2); \
|
|
}
|
|
#define COVERAGE_CALL_ARGS3(FUNC, PARAM1, PARAM2, PARAM3) \
|
|
{ \
|
|
LOG(Info, #FUNC); \
|
|
scriptTwo->FUNC(PARAM1, PARAM2, PARAM3); \
|
|
}
|
|
#define COVERAGE_CALL_ARGS4(FUNC, PARAM1, PARAM2, PARAM3, PARAM4) \
|
|
{ \
|
|
LOG(Info, #FUNC); \
|
|
scriptTwo->FUNC(PARAM1, PARAM2, PARAM3, PARAM4); \
|
|
}
|
|
#define COVERAGE_CALL_ARGS5(FUNC, PARAM1, PARAM2, PARAM3, PARAM4, PARAM5) \
|
|
{ \
|
|
LOG(Info, #FUNC); \
|
|
scriptTwo->FUNC(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5); \
|
|
}
|
|
#define COVERAGE_CALL_ARGS6(FUNC, PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6) \
|
|
{ \
|
|
LOG(Info, #FUNC); \
|
|
scriptTwo->FUNC(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6); \
|
|
}
|