[profiler_capture_api] replace profiler capture location cvar with setting registry entry
Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com>
This commit is contained in:
@@ -10,18 +10,16 @@
|
||||
#include <AzCore/Debug/ProfilerBus.h>
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzCore/Console/ILogger.h>
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
|
||||
namespace AZ::Debug
|
||||
{
|
||||
AZ_CVAR(AZ::CVarFixedString, bg_profilerCaptureLocation, "@user@/Profiler", nullptr, ConsoleFunctorFlags::Null,
|
||||
"Specify where to save profiler capture data");
|
||||
|
||||
AZStd::string GenerateOutputFile(const char* nameHint)
|
||||
{
|
||||
AZStd::string timeString;
|
||||
AZStd::to_string(timeString, AZStd::GetTimeNowSecond());
|
||||
|
||||
AZ::CVarFixedString captureOutput = static_cast<AZ::CVarFixedString>(bg_profilerCaptureLocation);
|
||||
AZ::IO::FixedMaxPathString captureOutput = GetProfilerCaptureLocation();
|
||||
|
||||
return AZStd::string::format("%s/capture_%s_%s.json", captureOutput.c_str(), nameHint, timeString.c_str());
|
||||
}
|
||||
@@ -47,4 +45,20 @@ namespace AZ::Debug
|
||||
AZ::Debug::ProfilerRequestBus::Broadcast(&AZ::Debug::ProfilerRequestBus::Events::EndCapture);
|
||||
}
|
||||
AZ_CONSOLEFREEFUNC(ProfilerEndCapture, AZ::ConsoleFunctorFlags::DontReplicate, "End and dump an in-progress continuous capture");
|
||||
|
||||
AZ::IO::FixedMaxPathString GetProfilerCaptureLocation()
|
||||
{
|
||||
AZ::IO::FixedMaxPathString captureOutput;
|
||||
if (AZ::SettingsRegistryInterface* settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry)
|
||||
{
|
||||
settingsRegistry->Get(captureOutput, RegistryKey_ProfilerCaptureLocation);
|
||||
}
|
||||
|
||||
if (captureOutput.empty())
|
||||
{
|
||||
captureOutput = ProfilerCaptureLocationFallback;
|
||||
}
|
||||
|
||||
return captureOutput;
|
||||
}
|
||||
} // namespace AZ::Debug
|
||||
|
||||
@@ -10,12 +10,19 @@
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/IO/Path/Path_fwd.h>
|
||||
#include <AzCore/std/string/string.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace Debug
|
||||
{
|
||||
//! settings registry entry for specifying where to output profiler captures
|
||||
static constexpr const char* RegistryKey_ProfilerCaptureLocation = "/O3DE/AzCore/Debug/Profiler/CaptureLocation";
|
||||
|
||||
//! fallback value in the event the settings registry isn't ready or doesn't contain the key
|
||||
static constexpr const char* ProfilerCaptureLocationFallback = "@user@/Profiler";
|
||||
|
||||
/**
|
||||
* ProfilerNotifications provides a profiler event interface that can be used to update listeners on profiler status
|
||||
*/
|
||||
@@ -60,5 +67,9 @@ namespace AZ
|
||||
virtual bool EndCapture() = 0;
|
||||
};
|
||||
using ProfilerRequestBus = AZ::EBus<ProfilerRequests>;
|
||||
|
||||
//! helper function for getting the profiler capture location from the settings registry that
|
||||
//! includes fallback handing in the event the registry value can't be determined
|
||||
AZ::IO::FixedMaxPathString GetProfilerCaptureLocation();
|
||||
} // namespace Debug
|
||||
} // namespace AZ
|
||||
|
||||
Reference in New Issue
Block a user