2 ms·
qsort 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 implementat
by ridiculous_fish 12y ago
qsort 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.