You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
* Added -forkautostatsport cmdline option that automatically sets a unique port for each forked child. Ports used will start at statsPort+1. * Improved statsport /exec listener so it returns a different error message when the exec callback isn't registered, the cmd itself was not processed by the exec or the cmd is missing the 'c=' param. Forking * Exposed ChildProcessIndex in ForkHelper [REVIEW] Brandon.Schaeffer, Brian.Bekich #ROBOMERGE-AUTHOR: louisphilippe.seguin #ROBOMERGE-SOURCE: CL 18770568 via CL 18770579 via CL 18770587 via CL 18774066 via CL 18774960 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472) [CL 18775041 by louisphilippe seguin in ue5-main branch]
90 lines
2.5 KiB
C++
90 lines
2.5 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "PerfCountersModule.h"
|
|
#include "HAL/PlatformProcess.h"
|
|
#include "PerfCounters.h"
|
|
#include "Misc/CommandLine.h"
|
|
#include "Misc/Fork.h"
|
|
|
|
class FPerfCountersModule : public IPerfCountersModule
|
|
{
|
|
private:
|
|
|
|
/** All created perf counter instances from this module */
|
|
TSharedPtr<FPerfCounters> PerfCountersSingleton = nullptr;
|
|
|
|
public:
|
|
|
|
FPerfCountersModule()
|
|
{
|
|
}
|
|
|
|
virtual void ShutdownModule() override
|
|
{
|
|
PerfCountersSingleton.Reset();
|
|
}
|
|
|
|
virtual bool SupportsDynamicReloading() override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
virtual bool SupportsAutomaticShutdown() override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
IPerfCounters* GetPerformanceCounters() const
|
|
{
|
|
return PerfCountersSingleton.Get();
|
|
}
|
|
|
|
IPerfCounters* CreatePerformanceCounters(const FString& UniqueInstanceId) override
|
|
{
|
|
if (PerfCountersSingleton)
|
|
{
|
|
UE_LOG(LogPerfCounters, Display, TEXT("CreatePerformanceCounters: instance already exists, new instance not created."));
|
|
return PerfCountersSingleton.Get();
|
|
}
|
|
|
|
FString InstanceUID = UniqueInstanceId;
|
|
if (InstanceUID.IsEmpty())
|
|
{
|
|
InstanceUID = FString::Printf(TEXT("perfcounters-of-pid-%d"), FPlatformProcess::GetCurrentProcessId());
|
|
}
|
|
|
|
PerfCountersSingleton = MakeShared<FPerfCounters>(InstanceUID);
|
|
if (!PerfCountersSingleton->Initialize())
|
|
{
|
|
UE_LOG(LogPerfCounters, Warning, TEXT("CreatePerformanceCounters: could not create perfcounters"));
|
|
return nullptr;
|
|
}
|
|
|
|
return PerfCountersSingleton.Get();
|
|
}
|
|
};
|
|
|
|
IMPLEMENT_MODULE(FPerfCountersModule, PerfCounters)
|
|
DEFINE_LOG_CATEGORY(LogPerfCounters);
|
|
|
|
const FName IPerfCounters::Histograms::FrameTime(TEXT("FrameTime"));
|
|
const FName IPerfCounters::Histograms::FrameTimePeriodic(TEXT("FrameTimePeriodic"));
|
|
const FName IPerfCounters::Histograms::FrameTimeWithoutSleep(TEXT("FrameTimeWithoutSleep"));
|
|
const FName IPerfCounters::Histograms::ServerReplicateActorsTime(TEXT("ServerReplicateActorsTime"));
|
|
const FName IPerfCounters::Histograms::SleepTime(TEXT("SleepTime"));
|
|
const FName IPerfCounters::Histograms::ZeroLoadFrameTime(TEXT("ZeroLoadFrameTime"));
|
|
|
|
int32 IPerfCountersModule::GetHTTPStatsPort()
|
|
{
|
|
int32 StatsPort = -1;
|
|
FParse::Value(FCommandLine::Get(), TEXT("statsPort="), StatsPort);
|
|
|
|
if (StatsPort > 0 && FParse::Param(FCommandLine::Get(), TEXT("forkAutoStatsPort")))
|
|
{
|
|
const int32 ChildProcessIdx = FForkProcessHelper::GetForkedChildProcessIndex();
|
|
StatsPort += ChildProcessIdx;
|
|
UE_LOG(LogPerfCounters, Display, TEXT("ForkAutoStatsPort assigned port %d to child process %d"), StatsPort, ChildProcessIdx);
|
|
}
|
|
|
|
return StatsPort;
|
|
} |