3 ms·
Under what compiler? On GCC 4.9 they're neck-and-neck:: qsort: 6727 ms std::sort: 6718 ms (CPU is Core i7-950)
by agwa 12y ago
Under what compiler? On GCC 4.9 they're neck-and-neck::
qsort: 6727 ms
std::sort: 6718 ms
(CPU is Core i7-950)
- ridiculous_fish 12y agoqsort wins by 2x with clang++ on OS X, 10x with g++-4.9 on OS X, and by about 14% with gcc 4.8 on Linux. This may be a pathological case for either implementation, since the array is already sorted. Still the point about std::sort requiring up to twice as many comparisons is valid.
- btmorex 12y agofwiw, on linux with g++-4.8.2: qsort: 4415 ms std::sort: 4413 ms Some comments: 1.) std::sort doesn't require twice as many comparisons 2.) You not only have a vector with equal items, you have a vector of the same item repeated. That removes all data cache issues which I think is generally unrealistic and unfair. 3.) An already sorted vector is not only pathological, it's something that you usually need to optimize for (probably both qsort and std::sort are bad choices)
- GFK_of_xmaspast 12y ago" the array is already sorted" Oh come on.