Dont overwrite profile data (#2440)

This way a user can take multiple data samples from one/multiple play
sessions quickly. Creates a directory called profile_data that is added
to gitignore to place the data in, and checks to see if a file is there
and if so it creates prof1.json prof2.json prof3.json and so on...
This commit is contained in:
ZedB0T
2023-03-29 18:24:28 -04:00
committed by GitHub
parent d6c5d32cd3
commit f04083d997
2 changed files with 28 additions and 2 deletions
+1
View File
@@ -11,6 +11,7 @@ cmake-build-debug--o0/*
build/*
/decompiler_out*
logs/*
profile_data/*
# for vscode/clangd
.cache/*
+27 -2
View File
@@ -8,6 +8,7 @@
#include <condition_variable>
#include <memory>
#include <mutex>
#include <sstream>
#include "common/dma/dma_copy.h"
#include "common/global_profiler/GlobalProfiler.h"
@@ -739,11 +740,35 @@ void update_global_profiler() {
if (g_gfx_data->debug_gui.dump_events) {
prof().set_enable(false);
g_gfx_data->debug_gui.dump_events = false;
prof().dump_to_json((file_util::get_jak_project_dir() / "prof.json").string());
std::string dir_path = (file_util::get_jak_project_dir() / "profile_data").string();
fs::create_directories(dir_path);
std::string file_path = (file_util::get_jak_project_dir() / "profile_data/prof.json").string();
std::ifstream file(file_path);
if (file.good()) {
file.close();
int file_index = 1;
while (true) {
std::stringstream ss;
ss << "profile_data/prof" << file_index << ".json";
std::string new_file_path = (file_util::get_jak_project_dir() / ss.str()).string();
std::ifstream new_file(new_file_path);
if (!new_file.good()) {
file_path = new_file_path;
break;
}
new_file.close();
file_index++;
}
} else {
file.close();
}
prof().dump_to_json(file_path);
}
prof().set_enable(g_gfx_data->debug_gui.record_events);
}
void GLDisplay::VMode::set(const GLFWvidmode* vmode) {
width = vmode->width;
height = vmode->height;