[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Thu Oct 6 18:53:26 CEST 2005


SVN commit 467874 by staikos:

add more benchmarking to illustrate problem with QPainter::drawText() being
randomly slow


 M  +16 -2     kstviewlabel.cpp  
 M  +9 -1      labelrenderer.cpp  


--- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #467873:467874
@@ -19,14 +19,15 @@
 #include "kstviewlabel.h"
 
 #include "enodes.h"
+#include "ksdebug.h"
 #include "kst.h"
 #include "kstdatacollection.h"
 #include "labelrenderer.h"
 #include "kstsettings.h"
+#include "ksttimers.h"
 
 
 #include <kdatastream.h>
-#include <kdebug.h>
 #include <kglobal.h>
 #include <klocale.h>
 #include <kpopupmenu.h>
@@ -277,14 +278,28 @@
   p.rotate(_rotation);
 
   rc.xStart = rc.x;
+#ifdef BENCHMARK
+  QTime t;
+  t.start();
+#endif
   renderLabel(rc, lp->chunk);
+#ifdef BENCHMARK
+  kstdDebug() << "render took: " << t.elapsed() << endl;
+#endif
 }
 
 
 void KstViewLabel::computeTextSize(Label::Parsed *lp) {
   RenderContext rc(_fontName, _symbolFontName, _absFontSize, 0L);
   rc.precision = _dataPrecision;
+#ifdef BENCHMARK
+  QTime t;
+  t.start();
+#endif
   renderLabel(rc, lp->chunk);
+#ifdef BENCHMARK
+  kstdDebug() << "compute (false render) took: " << t.elapsed() << endl;
+#endif
   _textWidth = rc.xMax;
   _ascent = rc.ascent;
   _textHeight = 1 + rc.ascent + rc.descent;
@@ -292,7 +307,6 @@
 
 
 void KstViewLabel::paint(KstPaintType type, QPainter& p) {
-
   if (type == P_PRINT) {
     p.save();
     if (_autoResize) {
--- trunk/extragear/graphics/kst/kst/labelrenderer.cpp #467873:467874
@@ -19,9 +19,10 @@
 
 #include "enodes.h"
 #include "kstdatacollection.h"
+#include "ksttimers.h"
 #include "labelparser.h"
 
-#include <kdebug.h>
+#include "ksdebug.h"
 #include <kglobal.h>
 
 
@@ -126,7 +127,14 @@
       rc.x += tabWidth - (rc.x - rc.xStart) % tabWidth;
     } else {
       if (rc.p) {
+#ifdef BENCHMARK
+        QTime t;
+        t.start();
+#endif
         rc.p->drawText(rc.x, rc.y, fi->text);
+#ifdef BENCHMARK
+        kstdDebug() << "Renderer did draw, time: " << t.elapsed() << endl;
+#endif
       }
       rc.x += rc.fontWidth(fi->text);
     }


More information about the Kst mailing list