Files
UnrealEngineUWP/Engine/Source/Runtime/PerfCounters/Private/PerfCountersModule.cpp
Ryan Vance 7c51ff94af Merging //UE4/Dev-Main to Dev-VR (//UE4/Dev-VR)
CL 1 of 8
#rb integration

[CL 4748712 by Ryan Vance in Dev-VR branch]
2019-01-17 18:54:05 -05:00

80 lines
2.1 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "PerfCountersModule.h"
#include "HAL/PlatformProcess.h"
#include "PerfCounters.h"
class FPerfCountersModule : public IPerfCountersModule
{
private:
/** All created perf counter instances from this module */
FPerfCounters* PerfCountersSingleton;
public:
FPerfCountersModule() :
PerfCountersSingleton(NULL)
{}
void ShutdownModule()
{
if (PerfCountersSingleton)
{
delete PerfCountersSingleton;
PerfCountersSingleton = nullptr;
}
}
virtual bool SupportsDynamicReloading() override
{
return false;
}
virtual bool SupportsAutomaticShutdown() override
{
return false;
}
IPerfCounters* GetPerformanceCounters() const
{
return PerfCountersSingleton;
}
IPerfCounters* CreatePerformanceCounters(const FString& UniqueInstanceId) override
{
if (PerfCountersSingleton)
{
UE_LOG(LogPerfCounters, Display, TEXT("CreatePerformanceCounters: instance already exists, new instance not created."));
return PerfCountersSingleton;
}
FString InstanceUID = UniqueInstanceId;
if (InstanceUID.IsEmpty())
{
InstanceUID = FString::Printf(TEXT("perfcounters-of-pid-%d"), FPlatformProcess::GetCurrentProcessId());
}
FPerfCounters* PerfCounters = new FPerfCounters(InstanceUID);
if (!PerfCounters->Initialize())
{
UE_LOG(LogPerfCounters, Warning, TEXT("CreatePerformanceCounters: could not create perfcounters"));
delete PerfCounters;
return nullptr;
}
PerfCountersSingleton = PerfCounters;
return PerfCounters;
}
};
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"));