[Kst] kdeextragear-2/kst/kst

Barth Netterfield netterfield at astro.utoronto.ca
Wed Dec 15 16:06:47 CET 2004


CVS commit by netterfield: 

Add some kdDebug benchmark info on how long (wall clock) various drawing
things take.

To deactivate, remove #define PLOTBENCH in kst2dplot.cpp

Some notes from the bus ride home:
-for ~100000 or more points, curve drawing completely dominates.
-labels (labels + axis) are #2
-Every other curve draw is ~70% longer.  Why???
-loading from the command line draws once.  Loading the exact same thing
from a .kst file draws 3 times, the second time very slowly.


  M +66 -5     kst2dplot.cpp   1.323


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.322:1.323
@@ -49,4 +49,7 @@
 #include "kstvectordialog_i.h"
 
+// if defined, print wallclock benchmarking info about plot drawing...
+#define PLOTBENCH
+
 #define JD1900                  2415020.5
 #define JD1970                  2440587.5
@@ -2008,4 +2011,13 @@ void Kst2DPlot::draw(QPainter &p, KstPai
   int penWidth;
 
+#ifdef PLOTBENCH
+  QTime bench_time;
+  int i_bt=0, bt[15];
+  QString bt_label[15];
+
+  bench_time.start();
+#endif
+
+
   p.setWindow(0, 0, (int)(p.viewport().width() * resolutionEnhancement),
                     (int)(p.viewport().height() * resolutionEnhancement));
@@ -2088,8 +2100,18 @@ void Kst2DPlot::draw(QPainter &p, KstPai
     }
 
+#ifdef PLOTBENCH
+    bt_label[i_bt] = "Initialization";
+    bt[i_bt++] = bench_time.elapsed();
+#endif
     plotLabels(p, x_px, y_px, xleft_bdr_px, ytop_bdr_px);
-
+#ifdef PLOTBENCH
+    bt_label[i_bt] = "Plot Labels";
+    bt[i_bt++] = bench_time.elapsed();
+#endif
     plotImages(p, Lx, Hx, Ly, Hy, m_X, m_Y, b_X, b_Y, x_max, y_max, x_min, y_min);
-
+#ifdef PLOTBENCH
+    bt_label[i_bt] = "Plot Images";
+    bt[i_bt++] = bench_time.elapsed();
+#endif
     //
     // must plot grid lines before axes
@@ -2099,4 +2121,8 @@ void Kst2DPlot::draw(QPainter &p, KstPai
                   tpy.tick, ytop_bdr_px, ybot_bdr_px, y_orig_px, ytick_px, ytick_len_px, y_px);
 
+#ifdef PLOTBENCH
+    bt_label[i_bt] = "Plot Grid Lines";
+    bt[i_bt++] = bench_time.elapsed();
+#endif
     //
     // plot the legend now if its in the background
@@ -2106,8 +2133,15 @@ void Kst2DPlot::draw(QPainter &p, KstPai
           d2i(xleft_bdr_px + double(RelPlotRegion.width()) * Legend->x()),
           d2i(ytop_bdr_px + double(RelPlotRegion.height()) * Legend->y()));
+#ifdef PLOTBENCH
+      bt_label[i_bt] = "plot Legend";
+      bt[i_bt++] = bench_time.elapsed();
+#endif    
     }
 
     plotCurves(p, Lx, Hx, Ly, Hy, m_X, m_Y, b_X, b_Y, penWidth);
-
+#ifdef PLOTBENCH
+    bt_label[i_bt] = "Plot Curves";
+    bt[i_bt++] = bench_time.elapsed();
+#endif
     p.setPen(QPen(_foregroundColor, penWidth));
     plotAxes(p, RelPlotRegion,
@@ -2115,7 +2149,13 @@ void Kst2DPlot::draw(QPainter &p, KstPai
         tpy, ytop_bdr_px, ybot_bdr_px, y_orig_px, ytick_px, ytick_len_px, y_px,
         offsetX, offsetY);
-
+#ifdef PLOTBENCH
+    bt_label[i_bt] = "plot Axes";
+    bt[i_bt++] = bench_time.elapsed();
+#endif
     plotPlotMarkers(p, m_X, b_X, x_max, x_min, y_px, ytop_bdr_px, ybot_bdr_px);
-
+#ifdef PLOTBENCH
+    bt_label[i_bt] = "plot Markers";
+    bt[i_bt++] = bench_time.elapsed();
+#endif
     //
     // plot the legend now if its in the foreground
@@ -2125,4 +2165,8 @@ void Kst2DPlot::draw(QPainter &p, KstPai
           d2i(xleft_bdr_px + double(RelPlotRegion.width()) * Legend->x()),
           d2i(ytop_bdr_px + double(RelPlotRegion.height()) * Legend->y()));
+#ifdef PLOTBENCH
+      bt_label[i_bt] = "plot Legend";
+      bt[i_bt++] = bench_time.elapsed();
+#endif    
     }
 
@@ -2133,7 +2177,24 @@ void Kst2DPlot::draw(QPainter &p, KstPai
       label->draw(p, d2i(xleft_bdr_px + double(RelPlotRegion.width()) * label->x()),
                   d2i(ytop_bdr_px + double(RelPlotRegion.height()) * label->y()));
+#ifdef PLOTBENCH
+      bt_label[i_bt] = "plot Legend";
+      bt[i_bt++] = bench_time.elapsed();
+#endif    
     }
 
     p.flush();
+
+#ifdef PLOTBENCH
+    bt_label[i_bt] = "Flush Painter";
+    bt[i_bt++] = bench_time.elapsed();
+
+    int j;
+    kdDebug() << "Plot Benchmark stats:" << endl;
+    kdDebug() << "   " << bt_label[0] << ": " << bt[0] << "ms" << endl;
+    for (j=1; j<i_bt; j++) {
+      kdDebug() << "   " << bt_label[j] << ": " << bt[j]-bt[j-1] << "ms" << endl;
+    }
+    kdDebug() << "Plot Total: " << bt[i_bt-1] << "ms" << endl;
+#endif
   }
 





More information about the Kst mailing list