Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profiler/GPUViz: Stop allocating memory #4308

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions FEXCore/Source/Utils/Profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,19 @@ void Shutdown() {
void TraceObject(std::string_view const Format, uint64_t Duration) {
if (TraceFD != -1) {
// Print the duration as something that began negative duration ago
fextl::string Event = fextl::fmt::format("{} (lduration=-{})\n", Format, Duration);
write(TraceFD, Event.c_str(), Event.size());
const auto StringSize = Format.size() + strlen(" (lduration=-)\n") + 22;
auto Event = reinterpret_cast<char*>(alloca(StringSize));
auto Res = ::fmt::format_to_n(Event, StringSize, "{} (lduration=-{})\n", Format, Duration);
write(TraceFD, Event, Res.size);
}
}

void TraceObject(std::string_view const Format) {
if (TraceFD != -1) {
fextl::string Event = fextl::fmt::format("{}\n", Format);
write(TraceFD, Event.data(), Event.size());
const auto StringSize = Format.size() + 1;
auto Event = reinterpret_cast<char*>(alloca(StringSize));
auto Res = ::fmt::format_to_n(Event, StringSize, "{}\n", Format);
write(TraceFD, Event, Res.size);
}
}
} // namespace GPUVis
Expand Down
Loading