logging: fix percentiles miscalculation

mangoconfig
FlightlessMango 8 months ago
parent 4bc55bf966
commit 13164b01ad

@ -272,7 +272,9 @@ void Logger::calculate_benchmark_data(){
for (auto& point : m_log_array) for (auto& point : m_log_array)
sorted.push_back(point.frametime); sorted.push_back(point.frametime);
std::sort(sorted.begin(), sorted.end()); std::sort(sorted.begin(), sorted.end(), [](float a, float b) {
return a > b;
});
benchmark.percentile_data.clear(); benchmark.percentile_data.clear();
benchmark.total = 0.f; benchmark.total = 0.f;
@ -301,14 +303,11 @@ void Logger::calculate_benchmark_data(){
benchmark.percentile_data.push_back({percentile, (1000 / result)}); benchmark.percentile_data.push_back({percentile, (1000 / result)});
} }
string label; string label;
float mins[2] = {0.01f, 0.001f}, total; float mins[2] = {0.01f, 0.001f};
for (auto percent : mins){ for (auto percent : mins){
total = 0; size_t percentile_pos = sorted.size() * percent;
size_t idx = ceil(sorted.size() * percent); percentile_pos = std::min(percentile_pos, sorted.size() - 1);
for (size_t i = 0; i < idx; i++){ float result = 1000 / sorted[percentile_pos];
total = total + sorted[i];
}
result = 1000 / (total / idx);
if (percent == 0.001f) if (percent == 0.001f)
label = "0.1%"; label = "0.1%";

Loading…
Cancel
Save