[Qgis-developer] STL vs. Qt containers

Mateusz Loskot mateusz at loskot.net
Sat Oct 28 20:52:43 EDT 2006


I'd like also to suggest to measure performance of QT and STL containers
with basic algorithms.

What QT is supposed to be used, 4.1 or 4.2?

For example, in QT 4.1 there is no QSet::find algorithm,
so iterator-based searching is
- 16 times slower in searching for present value (100000)
- 56 times slower in searching for not present value in a set (600000)

// myqset contains values from 0 to 399999
int n = 0;
int idle = 100000;
QSet<int>::const_iterator end = myqset.end();
for (QSet<int>::const_iterator it = myqset.begin(); it != end; ++it)
{
   if (idle == *it)
      n = *it;
}

than dedicated find algorithm for tree structures (std::set and
std::map) in STL:

// myset contains values from 0 to 399999
int n = 0;
int idle = 100000;
set<int>::const_iterator pos = myset.find(idle);
if (myset.end() != pos)
   n = *pos;



If QGIS is supposed to work with all QT 4.x versions, then it's
required to use old API, compatible with all versions and it's not
possible to use ie. QSet::find algorithm.
That may increase performance significantly and 4.2 users won't be able
to use new and robust versions because QGIS needs to work with QT 4.1, etc.
Such problems does not exist if STL is used.

I'm just trying to point as much issues as possible, that I believe
should be considered before making decision to move to QT containers
completely.
I think, simple voting is a bad idea :-) because it's about engineering,
so measurements are the only way to select one solution over another.

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the Qgis-developer mailing list