Børge Austvold wrote: > > Hi, > > I had some available time now before x-mas and did some tests on OpenGL > performance. I had a feeling for some reasons that writing OpenGL > applications in Java had be to slower that native ones in C++. So, to > test this I fired up an simple application that paints 10000 rectangles > and 50 images with some opacity using a QPainter on a QGLWidget. I wrote > the same application in C++ using QT 4.4 and in Java using Jambi 4.4. On > the first run the java application stopped every 5th second to garbage > collect. When I removed all allocations and cached some random > calculations (in both c++ and java) the java application is running 30% > faster on my Dell M90 laptop running both Linux Mint (Ubuntu 8.10) and > Windows Vista. The linux version in java (and c++) is also running > significant faster than on Vista. > > Did some more testing and It seems like the java version is always > faster than the c++ version. The only exception was when I tested this > on a KDE 4.1 machine. There the C++ version ran faster.... How can this > be possible? Is the HotSpot stuff from sun able to optimize passed the > JNI in the stack ? > > Any thoughts on this ?
There are two reasons for the difference that I can see. The startup time to get the pixmap loaded into graphics memory etc seems to be a bit costly, so I reset the timer every 5 sec. Then I noticed that you preincrement the counter in java and postincrement it in C++, meaning that you will count one less frame in C++, and since the code is running at 19 Fps (at least on my machine, this will affect the output). The initialization of the data is also quite different and the speed is dependent on how much of the pixels are being written and read and speed is far more dependent on how much you're actually drawing than on the runtime. If you sync up the implementations, the two will perform pretty much identical. best regards, Gunnar _______________________________________________ Qt-jambi-interest mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest
