Browse Source

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
rdb 1 year ago
parent
commit
91c22a0fd6
1 changed files with 10 additions and 1 deletions
  1. 10 1
      pandatool/src/pstatserver/pStatStripChart.cxx

+ 10 - 1
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);