Merge pull request #671 from Joshua-Ashton/empty_crash

Fix crash when no frames were recorded
pull/673/head
flightlessmango 2 years ago committed by GitHub
commit 0f49c5796a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -77,7 +77,7 @@ void writeSummary(string filename){
out << fixed << setprecision(1) << result << ",";
}
// 97th percentile
result = sorted[floor(0.97 * (sorted.size() - 1))].fps;
result = sorted.empty() ? 0.0f : sorted[floor(0.97 * (sorted.size() - 1))].fps;
out << fixed << setprecision(1) << result << ",";
// avg
total = 0;
@ -254,7 +254,7 @@ void Logger::calculate_benchmark_data(){
// the percentiles are already validated when they're parsed from the config.
float fraction = parse_float(percentile) / 100;
result = sorted[(fraction * sorted.size()) - 1];
result = sorted.empty() ? 0.0f : sorted[(fraction * sorted.size()) - 1];
percentile += "%";
}

@ -433,7 +433,7 @@ void render_benchmark(swapchain_stats& data, struct overlay_params& params, ImVe
ImGui::TextColored(ImVec4(1.0, 1.0, 1.0, alpha / params.background_alpha), "%s %.1f", data_.first.c_str(), data_.second);
}
float max = *max_element(benchmark.fps_data.begin(), benchmark.fps_data.end());
float max = benchmark.fps_data.empty() ? 0.0f : *max_element(benchmark.fps_data.begin(), benchmark.fps_data.end());
ImVec4 plotColor = HUDElements.colors.frametime;
plotColor.w = alpha / params.background_alpha;
ImGui::PushStyleColor(ImGuiCol_PlotLines, plotColor);

Loading…
Cancel
Save