mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
Address review comments
This commit is contained in:
parent
684b616f0d
commit
d36a7a43c5
|
@ -9,8 +9,8 @@
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <fmt/chrono.h>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
#include <fmt/time.h>
|
|
||||||
#include "common/file_util.h"
|
#include "common/file_util.h"
|
||||||
#include "common/math_util.h"
|
#include "common/math_util.h"
|
||||||
#include "core/perf_stats.h"
|
#include "core/perf_stats.h"
|
||||||
|
@ -34,13 +34,13 @@ PerfStats::~PerfStats() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::time_t t = std::time(nullptr);
|
const std::time_t t = std::time(nullptr);
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
std::copy(perf_history.begin() + IgnoreFrames, 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);
|
const std::string& path = FileUtil::GetUserPath(FileUtil::UserPath::LogDir);
|
||||||
// %F Date format expanded is "%Y-%m-%d"
|
// %F Date format expanded is "%Y-%m-%d"
|
||||||
std::string filename =
|
const std::string filename =
|
||||||
fmt::format("{}/{:%F-%H-%M}_{:016X}.csv", path, *std::localtime(&t), title_id);
|
fmt::format("{}/{:%F-%H-%M}_{:016X}.csv", path, *std::localtime(&t), title_id);
|
||||||
FileUtil::IOFile file(filename, "w");
|
FileUtil::IOFile file(filename, "w");
|
||||||
file.WriteString(stream.str());
|
file.WriteString(stream.str());
|
||||||
|
@ -75,10 +75,12 @@ void PerfStats::EndGameFrame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
double PerfStats::GetMeanFrametime() {
|
double PerfStats::GetMeanFrametime() {
|
||||||
|
std::lock_guard lock{object_mutex};
|
||||||
|
|
||||||
if (current_index <= IgnoreFrames) {
|
if (current_index <= IgnoreFrames) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
double sum = std::accumulate(perf_history.begin() + IgnoreFrames,
|
const double sum = std::accumulate(perf_history.begin() + IgnoreFrames,
|
||||||
perf_history.begin() + current_index, 0);
|
perf_history.begin() + current_index, 0);
|
||||||
return sum / (current_index - IgnoreFrames);
|
return sum / (current_index - IgnoreFrames);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cstddef>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue