Address review comments

This commit is contained in:
James Rowe 2019-08-14 21:03:11 -06:00
parent 45be693f8c
commit 23e969dfdc
5 changed files with 22 additions and 18 deletions

View file

@ -261,7 +261,7 @@ camera_inner_flip =
log_filter = *:Info log_filter = *:Info
[Debugging] [Debugging]
# Record frame time data, can be found in the log directory # Record frame time data, can be found in the log directory. Boolean value
record_frame_times = record_frame_times =
# Port for listening to GDB connections. # Port for listening to GDB connections.
use_gdbstub=false use_gdbstub=false

View file

@ -255,7 +255,8 @@ void Config::ReadValues() {
qt_config->endGroup(); qt_config->endGroup();
qt_config->beginGroup("Debugging"); qt_config->beginGroup("Debugging");
Settings::values.record_frame_times = ReadSetting("record_frame_times", false).toBool(); // Intentionally not using the QT default setting as this is intended to be changed in the ini
Settings::values.record_frame_times = qt_config->value("record_frame_times", false).toBool();
Settings::values.use_gdbstub = ReadSetting("use_gdbstub", false).toBool(); Settings::values.use_gdbstub = ReadSetting("use_gdbstub", false).toBool();
Settings::values.gdbstub_port = ReadSetting("gdbstub_port", 24689).toInt(); Settings::values.gdbstub_port = ReadSetting("gdbstub_port", 24689).toInt();
@ -545,7 +546,8 @@ void Config::SaveValues() {
qt_config->endGroup(); qt_config->endGroup();
qt_config->beginGroup("Debugging"); qt_config->beginGroup("Debugging");
WriteSetting("record_frame_times", Settings::values.record_frame_times, false); // Intentionally not using the QT default setting as this is intended to be changed in the ini
qt_config->setValue("record_frame_times", Settings::values.record_frame_times);
WriteSetting("use_gdbstub", Settings::values.use_gdbstub, false); WriteSetting("use_gdbstub", Settings::values.use_gdbstub, false);
WriteSetting("gdbstub_port", Settings::values.gdbstub_port, 24689); WriteSetting("gdbstub_port", Settings::values.gdbstub_port, 24689);

View file

@ -183,8 +183,8 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window, u32 system_mo
timing = std::make_unique<Timing>(); timing = std::make_unique<Timing>();
kernel = std::make_unique<Kernel::KernelSystem>( kernel = std::make_unique<Kernel::KernelSystem>(*memory, *timing,
*memory, *timing, [this] { PrepareReschedule(); }, system_mode); [this] { PrepareReschedule(); }, system_mode);
if (Settings::values.use_cpu_jit) { if (Settings::values.use_cpu_jit) {
#ifdef ARCHITECTURE_x86_64 #ifdef ARCHITECTURE_x86_64
@ -321,6 +321,7 @@ void System::Shutdown() {
VideoCore::Shutdown(); VideoCore::Shutdown();
HW::Shutdown(); HW::Shutdown();
telemetry_session.reset(); telemetry_session.reset();
perf_stats.reset();
rpc_server.reset(); rpc_server.reset();
cheat_engine.reset(); cheat_engine.reset();
service_manager.reset(); service_manager.reset();

View file

@ -21,23 +21,24 @@ using std::chrono::microseconds;
// Purposefully ignore the first five frames, as there's a significant amount of overhead in // Purposefully ignore the first five frames, as there's a significant amount of overhead in
// booting that we shouldn't account for // booting that we shouldn't account for
constexpr size_t IGNORE_FRAMES = 5; constexpr std::size_t IgnoreFrames = 5;
namespace Core { namespace Core {
PerfStats::PerfStats(u64 title_id) : title_id(title_id) {} PerfStats::PerfStats(u64 title_id) : title_id(title_id) {}
PerfStats::~PerfStats() { PerfStats::~PerfStats() {
if (Settings::values.record_frame_times && title_id != 0) { if (!Settings::values.record_frame_times || title_id == 0) {
return;
}
std::ostringstream stream; std::ostringstream stream;
std::copy(perf_history.begin() + IGNORE_FRAMES, perf_history.begin() + current_index, std::copy(perf_history.begin() + IgnoreFrames, perf_history.begin() + current_index,
std::ostream_iterator<double>(stream, "\n")); std::ostream_iterator<double>(stream, "\n"));
std::string path = FileUtil::GetUserPath(FileUtil::UserPath::LogDir); std::string path = FileUtil::GetUserPath(FileUtil::UserPath::LogDir);
std::string filename = fmt::format("{}/{:X}.csv", path, title_id); std::string filename = fmt::format("{}/{:X}.csv", path, title_id);
FileUtil::IOFile file(filename, "w"); FileUtil::IOFile file(filename, "w");
file.WriteString(stream.str()); file.WriteString(stream.str());
} }
}
void PerfStats::BeginSystemFrame() { void PerfStats::BeginSystemFrame() {
std::lock_guard lock{object_mutex}; std::lock_guard lock{object_mutex};
@ -68,12 +69,12 @@ void PerfStats::EndGameFrame() {
} }
double PerfStats::GetMeanFrametime() { double PerfStats::GetMeanFrametime() {
if (current_index < 2) { if (current_index <= IgnoreFrames) {
return 0; return 0;
} }
double sum = std::accumulate(perf_history.begin() + IGNORE_FRAMES, double sum = std::accumulate(perf_history.begin() + IgnoreFrames,
perf_history.begin() + current_index, 0); perf_history.begin() + current_index, 0);
return sum / (current_index - 1 - IGNORE_FRAMES); return sum / (current_index - IgnoreFrames);
} }
PerfStats::Results PerfStats::GetAndResetStats(microseconds current_system_time_us) { PerfStats::Results PerfStats::GetAndResetStats(microseconds current_system_time_us) {

View file

@ -59,7 +59,7 @@ private:
/// Title ID for the game that is running. 0 if there is no game running yet /// Title ID for the game that is running. 0 if there is no game running yet
u64 title_id{0}; u64 title_id{0};
/// Current index for writing to the perf_history array /// Current index for writing to the perf_history array
size_t current_index{0}; std::size_t current_index{0};
/// Stores an hour of historical frametime data useful for processing and tracking performance /// Stores an hour of historical frametime data useful for processing and tracking performance
/// regressions with code changes. /// regressions with code changes.
std::array<double, 216000> perf_history = {}; std::array<double, 216000> perf_history = {};