Move calc benchmark into logger

doometernal
FlightlessMango 2 years ago
parent 496fa0babc
commit 7c3efb7403

@ -167,7 +167,7 @@ void Logger::stop_logging() {
m_logging_on = false;
m_log_end = Clock::now();
calculate_benchmark_data(m_params);
calculate_benchmark_data();
if(!m_params->output_folder.empty()) {
std::string program = get_wine_exe_name();
@ -228,3 +228,40 @@ void autostart_log(int sleep) {
os_time_sleep(sleep * 1000000);
logger->start_logging();
}
void Logger::calculate_benchmark_data(){
vector<float> sorted = benchmark.fps_data;
std::sort(sorted.begin(), sorted.end());
benchmark.percentile_data.clear();
benchmark.total = 0.f;
for (auto fps_ : sorted){
benchmark.total = benchmark.total + fps_;
}
size_t max_label_size = 0;
for (std::string percentile : m_params->benchmark_percentiles) {
float result;
// special case handling for a mean-based average
if (percentile == "AVG") {
result = benchmark.total / sorted.size();
} else {
// the percentiles are already validated when they're parsed from the config.
float fraction = parse_float(percentile) / 100;
result = sorted[(fraction * sorted.size()) - 1];
percentile += "%";
}
if (percentile.length() > max_label_size)
max_label_size = percentile.length();
benchmark.percentile_data.push_back({percentile, result});
}
for (auto& entry : benchmark.percentile_data) {
entry.first.append(max_label_size - entry.first.length(), ' ');
}
}

@ -52,6 +52,7 @@ public:
void upload_last_log();
void upload_last_logs();
void calculate_benchmark_data();
private:
std::vector<logData> m_log_array;
std::vector<std::string> m_log_files;

@ -208,44 +208,6 @@ void update_hud_info(struct swapchain_stats& sw_stats, struct overlay_params& pa
update_hud_info_with_frametime(sw_stats, params, vendorID, frametime_ns);
}
void calculate_benchmark_data(overlay_params* params){
vector<float> sorted = benchmark.fps_data;
std::sort(sorted.begin(), sorted.end());
benchmark.percentile_data.clear();
benchmark.total = 0.f;
for (auto fps_ : sorted){
benchmark.total = benchmark.total + fps_;
}
size_t max_label_size = 0;
for (std::string percentile : params->benchmark_percentiles) {
float result;
// special case handling for a mean-based average
if (percentile == "AVG") {
result = benchmark.total / sorted.size();
} else {
// the percentiles are already validated when they're parsed from the config.
float fraction = parse_float(percentile) / 100;
result = sorted[(fraction * sorted.size()) - 1];
percentile += "%";
}
if (percentile.length() > max_label_size)
max_label_size = percentile.length();
benchmark.percentile_data.push_back({percentile, result});
}
for (auto& entry : benchmark.percentile_data) {
entry.first.append(max_label_size - entry.first.length(), ' ');
}
}
float get_time_stat(void *_data, int _idx)
{
struct swapchain_stats *data = (struct swapchain_stats *) _data;

Loading…
Cancel
Save