3 ms·
FTA: By inlining C++ is able to run just the raw algorithm. On the opposite the C code has a number of indirections That is a reflection of using qsort ra
by veyron 15y ago
FTA:
By inlining C++ is able to run just the raw algorithm. On the opposite the C code has a number of indirections
That is a reflection of using qsort rather than rolling your own sort. You could write your own macro that replicates what std::sort does and see better performance in C. That same abstraction can be built in C.
If you want to argue that the C++ standard library has more utilities to simplify these optimizations, certainly I will agree. I think, however, that the statement that "sorting in C++ is 3 times faster than C" is an unsubstantiated leap.
- moonchrome 15y agoBy rolling your own I meant manually unroling a sort for each type instance you use it for. Sure you can use a macro but that's just nasty. Anyway I don't think anyone thinks C++ is magic but I guess the title could be cleaner "sorting with standard libraries C++ 3 times faster".