Add Stopwatch for accurate duration measuring

This commit is contained in:
Wojtek Figat
2024-01-28 20:31:03 +01:00
parent ecf593e7a4
commit 69b7a10c1f
10 changed files with 113 additions and 41 deletions

View File

@@ -23,7 +23,7 @@
#include "Internal/StdTypesContainer.h"
#include "Engine/Core/ObjectsRemovalService.h"
#include "Engine/Core/Types/TimeSpan.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Core/Types/Stopwatch.h"
#include "Engine/Content/Asset.h"
#include "Engine/Content/Content.h"
#include "Engine/Engine/EngineService.h"
@@ -31,6 +31,7 @@
#include "Engine/Engine/Time.h"
#include "Engine/Graphics/RenderTask.h"
#include "Engine/Serialization/JsonTools.h"
#include "Engine/Profiler/ProfilerCPU.h"
extern void registerFlaxEngineInternalCalls();
@@ -126,7 +127,7 @@ void onEngineUnloading(MAssembly* assembly);
bool ScriptingService::Init()
{
const auto startTime = DateTime::NowUTC();
Stopwatch stopwatch;
// Initialize managed runtime
if (MCore::LoadEngine())
@@ -158,9 +159,8 @@ bool ScriptingService::Init()
return true;
}
auto endTime = DateTime::NowUTC();
LOG(Info, "Scripting Engine initializated! (time: {0}ms)", (int32)((endTime - startTime).GetTotalMilliseconds()));
stopwatch.Stop();
LOG(Info, "Scripting Engine initializated! (time: {0}ms)", stopwatch.GetMilliseconds());
return false;
}
@@ -357,7 +357,7 @@ bool Scripting::LoadBinaryModules(const String& path, const String& projectFolde
if (!module)
{
// Load library
const auto startTime = DateTime::NowUTC();
Stopwatch stopwatch;
#if PLATFORM_ANDROID || PLATFORM_MAC
// On some platforms all native binaries are side-by-side with the app in a different folder
if (!FileSystem::FileExists(nativePath))
@@ -390,8 +390,8 @@ bool Scripting::LoadBinaryModules(const String& path, const String& projectFolde
LOG(Error, "Failed to setup library '{0}' for binary module {1}.", nativePath, name);
return true;
}
const auto endTime = DateTime::NowUTC();
LOG(Info, "Module {0} loaded in {1}ms", name, (int32)(endTime - startTime).GetTotalMilliseconds());
stopwatch.Stop();
LOG(Info, "Module {0} loaded in {1}ms", name, stopwatch.GetMilliseconds());
// Get the binary module
module = getBinaryFunc();