Add even more profiler events

This commit is contained in:
Wojtek Figat
2021-07-07 15:15:33 +02:00
parent afc5bb5731
commit 6938821467
13 changed files with 115 additions and 18 deletions

View File

@@ -16,6 +16,7 @@
#include "Engine/Content/Factories/JsonAssetFactory.h"
#include "Engine/Core/Cache.h"
#include "Engine/Debug/Exceptions/JsonParseException.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Scripting/Scripting.h"
#include "Engine/Utilities/StringConverter.h"
@@ -31,6 +32,7 @@ String JsonAssetBase::GetData() const
{
if (Data == nullptr)
return String::Empty;
PROFILE_CPU_NAMED("JsonAsset.GetData");
// Get serialized data
rapidjson_flax::StringBuffer buffer;
@@ -133,7 +135,10 @@ Asset::LoadResult JsonAssetBase::loadAsset()
#endif
// Parse json document
Document.Parse(data.Get<char>(), data.Length());
{
PROFILE_CPU_NAMED("Json.Parse");
Document.Parse(data.Get<char>(), data.Length());
}
if (Document.HasParseError())
{
Log::JsonParseException(Document.GetParseError(), Document.GetErrorOffset());

View File

@@ -8,6 +8,7 @@
#include "Engine/Serialization/JsonWriters.h"
#include "Engine/Level/Types.h"
#include "Engine/Debug/Exceptions/JsonParseException.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include <ThirdParty/rapidjson/document.h>
bool JsonStorageProxy::IsValidExtension(const StringView& extension)
@@ -17,6 +18,7 @@ bool JsonStorageProxy::IsValidExtension(const StringView& extension)
bool JsonStorageProxy::GetAssetInfo(const StringView& path, Guid& resultId, String& resultDataTypeName)
{
PROFILE_CPU();
// TODO: we could just open file and start reading until we find 'ID:..' without parsing whole file - could be much more faster
// Load file
@@ -28,7 +30,10 @@ bool JsonStorageProxy::GetAssetInfo(const StringView& path, Guid& resultId, Stri
// Parse data
rapidjson_flax::Document document;
document.Parse((const char*)fileData.Get(), fileData.Count());
{
PROFILE_CPU_NAMED("Json.Parse");
document.Parse((const char*)fileData.Get(), fileData.Count());
}
if (document.HasParseError())
{
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset(), path);
@@ -81,6 +86,7 @@ void ChangeIds(rapidjson_flax::Value& obj, rapidjson_flax::Document& document, c
bool JsonStorageProxy::ChangeId(const StringView& path, const Guid& newId)
{
#if USE_EDITOR
PROFILE_CPU();
// Load file
Array<byte> fileData;
@@ -91,7 +97,10 @@ bool JsonStorageProxy::ChangeId(const StringView& path, const Guid& newId)
// Parse data
rapidjson_flax::Document document;
document.Parse((const char*)fileData.Get(), fileData.Count());
{
PROFILE_CPU_NAMED("Json.Parse");
document.Parse((const char*)fileData.Get(), fileData.Count());
}
if (document.HasParseError())
{
Log::JsonParseException(document.GetParseError(), document.GetErrorOffset(), path);