From 4721f44b928365e930124d3cefa49cecacfe325c Mon Sep 17 00:00:00 2001 From: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com> Date: Fri, 29 Oct 2021 17:19:38 -0700 Subject: [PATCH] [profiler_capture_api] more changes based on PR feedback Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com> --- Code/Framework/AzCore/AzCore/Debug/Profiler.cpp | 8 ++------ Code/Framework/AzCore/AzCore/Debug/ProfilerReflection.cpp | 3 ++- Gems/Profiler/Code/Source/ImGuiCpuProfiler.cpp | 5 +---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Debug/Profiler.cpp b/Code/Framework/AzCore/AzCore/Debug/Profiler.cpp index 3b6b3b7e7a..0cb77b2d6e 100644 --- a/Code/Framework/AzCore/AzCore/Debug/Profiler.cpp +++ b/Code/Framework/AzCore/AzCore/Debug/Profiler.cpp @@ -16,12 +16,8 @@ namespace AZ::Debug { AZStd::string GenerateOutputFile(const char* nameHint) { - AZStd::string timeString; - AZStd::to_string(timeString, AZStd::GetTimeNowSecond()); - AZ::IO::FixedMaxPathString captureOutput = GetProfilerCaptureLocation(); - - return AZStd::string::format("%s/capture_%s_%s.json", captureOutput.c_str(), nameHint, timeString.c_str()); + return AZStd::string::format("%s/capture_%s_%lld.json", captureOutput.c_str(), nameHint, AZStd::GetTimeNowSecond()); } void ProfilerCaptureFrame([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments) @@ -41,7 +37,7 @@ namespace AZ::Debug { AZStd::string captureFile = GenerateOutputFile("multi"); AZLOG_INFO("Setting capture file to %s", captureFile.c_str()); - profilerSystem->StartCapture(captureFile); + profilerSystem->StartCapture(AZStd::move(captureFile)); } } AZ_CONSOLEFREEFUNC(ProfilerStartCapture, AZ::ConsoleFunctorFlags::DontReplicate, "Start a multi-frame capture of profiling data"); diff --git a/Code/Framework/AzCore/AzCore/Debug/ProfilerReflection.cpp b/Code/Framework/AzCore/AzCore/Debug/ProfilerReflection.cpp index 3455400cfe..42151a6996 100644 --- a/Code/Framework/AzCore/AzCore/Debug/ProfilerReflection.cpp +++ b/Code/Framework/AzCore/AzCore/Debug/ProfilerReflection.cpp @@ -74,7 +74,8 @@ namespace AZ::Debug ->Method("GetCaptureLocation", [](ProfilerSystemScriptProxy*) -> AZStd::string { - return AZStd::string(GetProfilerCaptureLocation().c_str()); + AZ::IO::FixedMaxPathString captureOutput = GetProfilerCaptureLocation(); + return AZStd::string(captureOutput.c_str(), captureOutput.length()); }) ->Method("IsActive", ProfilerSystemScriptProxy::WrapMethod<&ProfilerRequests::IsActive>()) diff --git a/Gems/Profiler/Code/Source/ImGuiCpuProfiler.cpp b/Gems/Profiler/Code/Source/ImGuiCpuProfiler.cpp index e1a734136b..26c2f9f974 100644 --- a/Gems/Profiler/Code/Source/ImGuiCpuProfiler.cpp +++ b/Gems/Profiler/Code/Source/ImGuiCpuProfiler.cpp @@ -402,13 +402,10 @@ namespace Profiler AZStd::string ImGuiCpuProfiler::GenerateOutputFile(const char* nameHint) { - AZStd::string timeString; - AZStd::to_string(timeString, AZStd::GetTimeNowSecond()); - AZ::IO::FixedMaxPathString captureOutput = AZ::Debug::GetProfilerCaptureLocation(); const AZ::IO::FixedMaxPathString frameDataFilePath = - AZ::IO::FixedMaxPathString::format("%s/cpu_%s_%s.json", captureOutput.c_str(), nameHint, timeString.c_str()); + AZ::IO::FixedMaxPathString::format("%s/cpu_%s_%lld.json", captureOutput.c_str(), nameHint, AZStd::GetTimeNowSecond()); AZ::IO::FileIOBase::GetInstance()->ResolvePath(m_lastCapturedFilePath, frameDataFilePath.c_str());