Add automatic profiler events for Visual Script methods invocation
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "Engine/Serialization/MemoryWriteStream.h"
|
||||
#include "Engine/Serialization/Serialization.h"
|
||||
#include "Engine/Serialization/JsonWriter.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Engine/Utilities/StringConverter.h"
|
||||
#include "FlaxEngine.Gen.h"
|
||||
|
||||
@@ -1329,6 +1330,7 @@ Asset::LoadResult VisualScript::load()
|
||||
{
|
||||
case GRAPH_NODE_MAKE_TYPE(16, 3):
|
||||
{
|
||||
// Override method
|
||||
auto& method = _methods.AddOne();
|
||||
method.Script = this;
|
||||
method.Node = &node;
|
||||
@@ -1342,6 +1344,7 @@ Asset::LoadResult VisualScript::load()
|
||||
}
|
||||
case GRAPH_NODE_MAKE_TYPE(16, 6):
|
||||
{
|
||||
// Function
|
||||
auto& method = _methods.AddOne();
|
||||
method.Script = this;
|
||||
method.Node = &node;
|
||||
@@ -1380,6 +1383,17 @@ Asset::LoadResult VisualScript::load()
|
||||
}
|
||||
}
|
||||
}
|
||||
#if COMPILE_WITH_PROFILER
|
||||
for (auto& method : _methods)
|
||||
{
|
||||
const StringView assetName(StringUtils::GetFileNameWithoutExtension(GetPath()));
|
||||
method.ProfilerName.Resize(assetName.Length() + 2 + method.Name.Length());
|
||||
StringUtils::ConvertUTF162ANSI(assetName.Get(), method.ProfilerName.Get(), assetName.Length());
|
||||
method.ProfilerName.Get()[assetName.Length()] = ':';
|
||||
method.ProfilerName.Get()[assetName.Length() + 1] = ':';
|
||||
Platform::MemoryCopy(method.ProfilerName.Get() + assetName.Length() + 2, method.Name.Get(), method.Name.Length());
|
||||
}
|
||||
#endif
|
||||
|
||||
// Setup fields list
|
||||
_fields.Resize(Graph.Parameters.Count());
|
||||
@@ -2284,6 +2298,7 @@ VisualScriptingBinaryModule* VisualScripting::GetBinaryModule()
|
||||
Variant VisualScripting::Invoke(VisualScript::Method* method, ScriptingObject* instance, Span<Variant> parameters)
|
||||
{
|
||||
CHECK_RETURN(method && method->Script->IsLoaded(), Variant::Zero);
|
||||
PROFILE_CPU_NAMED(*method->ProfilerName);
|
||||
|
||||
// Add to the calling stack
|
||||
ScopeContext scope;
|
||||
|
||||
@@ -115,6 +115,9 @@ public:
|
||||
MethodFlags MethodFlags;
|
||||
ScriptingTypeMethodSignature Signature;
|
||||
Array<StringAnsi, InlinedAllocation<16>> ParamNames;
|
||||
#if COMPILE_WITH_PROFILER
|
||||
StringAnsi ProfilerName;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct Field
|
||||
|
||||
Reference in New Issue
Block a user