Value-based classes: struct vs shared-data
David Faure
faure at kde.org
Sat Sep 30 00:39:27 CEST 2006
On Friday 29 September 2006 22:54, Roger Larsson wrote:
> On Friday 29 September 2006 14:31, David Faure wrote:
>
> > Any mistakes in my test? ;)
> >
>
> You did not tell what compiler (version) and options you used.
> But I guess it was unoptimized...
gcc-4.0.3, default kde-trunk buildsystem options with debugfull enabled.
Let's see what happens with -O2 instead of -g3 -fno-inline...
QDEBUG : KFileItemTest::testPerformance() CTOR: Simple struct: 16
QDEBUG : KFileItemTest::testPerformance() CTOR: With QSharedDataPointer: 18
QDEBUG : KFileItemTest::testPerformance() COPY CTOR: Simple struct: 5
QDEBUG : KFileItemTest::testPerformance() COPY CTOR: With QSharedDataPointer: 1
Hey that's pretty good. The performance hit for the default ctor is down to 12%
while the performance hit for the copy ctor when not using qshareddatapointer
is still very high (around 500%, although with '1' the number is too small to mean anything).
This seems to confirm that I should go ahead with QSharedDataPointer.
--
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the Kde-optimize
mailing list