Running my application under OSX Leopard and Windows XP, using bootcamp,  
hence with the same hardware, I have always noticed that running under  
Windows seems much faster. For instance run Assistant and scroll and  
resize the window, it's quite a different feeling.
I have therefore run a very simplistic benchmark, see further.
Using the 4.5 rc1 32 bit supplied binaries, the results are (Mac Pro 2.8  
GHz), in RELEASE mode:

Under Windows:
With QImage as paint device: 78 ms
With direct QPainter device: 78 ms

Under OSX:
With QImage as paint device: 98 ms
With direct QPainter device: 562 ms

Hence:

1) Drawing to a QImage is meant to be platform independant,
this means here that the VC++ 2008 compiler seems about 20% faster that  
GCC.
I am wondering if using an alternate GCC version could help (LLVM-GCC 4.2  
?)

2) Using QPainter directly (OSX api) to draw is dead slow, 550% slower  
that drawing to QImage.
I am wondering if there is any interest to this? Is it even normal?

Philippe

//  
-----------------------------------------------------------------------------

#include <QtGui>

//#define       USE_IMAGE       1

class TMainWindow : public QMainWindow
{
public:
        TMainWindow();

        void    paintEvent(QPaintEvent* ev);

};

//  
-----------------------------------------------------------------------------

TMainWindow::TMainWindow()
        :
        QMainWindow(0)
{
        resize(800,400);
}

//  
-----------------------------------------------------------------------------

void TMainWindow::paintEvent(QPaintEvent*)
{
        QTime time;
        time.start();
        QRect r = rect();

        #if USE_IMAGE
        QImage image(r.size(), QImage::Format_RGB32);
        QPainter painter(&image);
        painter.initFrom(this);
        #else
        QPainter painter(this);
        #endif

        for (int i = 0; i < 100; i++)
        {
                painter.fillRect(r, QBrush(Qt::white));
                painter.setPen(Qt::blue);
                for (int j = 0; j < 100; j++)
                {
                        painter.drawLine(0, 0, qrand() % 1000, qrand() % 1000);
                }
        }

        QString s = QString::number(time.elapsed());
        s += " ms";
        painter.setBackgroundMode(Qt::OpaqueMode);
        painter.drawText(20, 60, s);

        #if USE_IMAGE
        QPainter painter0(this);
        painter0.drawImage(0, 0, image);
        #endif
}

//  
-----------------------------------------------------------------------------

int main(int argc, char** argv)
{
     QApplication app(argc, argv);
     TMainWindow w;
     w.show();
     return app.exec();
}

//  
-----------------------------------------------------------------------------
_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback

Reply via email to