From 91c22a0fd68ec11e1a54a74ee50b970c3653928a Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 15 Mar 2024 12:45:19 +0100 Subject: [PATCH] pstats: Perf improvement for smooth mode in strip chart with dropped frames This significantly improves PStats strip chart performance with high frame rates and high number of dropped frames --- pandatool/src/pstatserver/pStatStripChart.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pandatool/src/pstatserver/pStatStripChart.cxx b/pandatool/src/pstatserver/pStatStripChart.cxx index 38f70f67eb..d961b7c055 100644 --- a/pandatool/src/pstatserver/pStatStripChart.cxx +++ b/pandatool/src/pstatserver/pStatStripChart.cxx @@ -672,16 +672,25 @@ compute_average_pixel_data(PStatStripChart::FrameData &result, double last = then_end; // Then we get all of each of the middle frames. + double weight = 0.0; for (int frame_number = then_i + 1; frame_number < now_i; frame_number++) { if (thread_data->has_frame(frame_number)) { + if (weight > 0.0) { + accumulate_frame_data(result, *fdata, weight); + weight = 0.0; + } fdata = &get_frame_data(frame_number); } - accumulate_frame_data(result, *fdata, fdata->_end - last); + weight += fdata->_end - last; last = fdata->_end; } + if (weight > 0.0) { + accumulate_frame_data(result, *fdata, weight); + } + // And finally, we get the remainder as now_i. if (last <= now) { accumulate_frame_data(result, get_frame_data(now_i), now - last);