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

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

View file

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