diff --git a/src/logging.cpp b/src/logging.cpp index d027bc06..ed49fc8d 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -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 += "%"; } diff --git a/src/overlay.cpp b/src/overlay.cpp index f04b7ce6..4e0a017b 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -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);