D10857: Change qSort to std::sort in simplifiedUrlList
Mark Gaiser
noreply at phabricator.kde.org
Tue Feb 27 12:13:56 UTC 2018
markg added a comment.
In D10857#214867 <https://phabricator.kde.org/D10857#214867>, @jtamate wrote:
> In D10857#214607 <https://phabricator.kde.org/D10857#214607>, @dfaure wrote:
>
> > I'm not opposed to the idea, but measuring CPU usage is a rather misleading indicator. What if it takes 10 times longer, because it's progressing much more slowly? ;)
> >
> > Please at least measure with QElapsedTimer around the sorting (not to be committed, just to gather numbers about the actual performance of this from a user's point of view).
> > I'm interested in the result ;)
>
>
> The results are strange. All the results are measured sorting 50.000 small files:
>
> Both Qt are the same version from opensuse.
>
> In an i5, why the difference is so big? recent cpu bugs?
> qSort in i3
> 274764, 276060 (with 3 directories), 365878, 424506 (without directories)
> std::sort in i3
> 940, 995 (with 3 directories), 2472, 2539 (without directories)
>
> In AMD the results are closer, qSort wins
> qSort in AMD
> 658, 726, 695, 683, 676, 666, 649, 684, 666 (without directories)
> std:sort in AMD
> 843, 839, 878, 896, 925 (without directories)
That surprises me a lot!
I "thought" qSort was just a template or alias to std::sort, but it isn't: http://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/tools/qalgorithms.h#n340
But it isn't which kinda makes my other expectations moot (qSort == std::sort... it isn't)
So i did some tests as well.
50000 filenames sorting them (computer sorting, not the natural one) with std::string and QString (yes, it matters)
Filenames, well, sorta.. Made them up in a loop :)
QString version: https://p.sc2.nl/r1JTFaf_z
qSort: ~220ms
std::sort ~276ms
std::string version: https://p.sc2.nl/HJ69Y6G_G
qSort: ~100ms
std::sort ~130ms
Note that std::string might not be the fair comparison as it's 8 bit/char. QString is 16.
My compiler (in this rare case) Visual Studio 2017 on an Intel CPU.
I still think it's wise to replace all qSort, if only for it being deprecated. But it does suck a little that qSort beats std::sort.
REPOSITORY
R241 KIO
REVISION DETAIL
https://phabricator.kde.org/D10857
To: jtamate, #frameworks, dfaure
Cc: markg, apol, michaelh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180227/9f9e44a1/attachment.html>
More information about the Kde-frameworks-devel
mailing list