4 ms·
One of the reasons for the performance difference is that you can't inline into the libc DLL blob: If you use qsort(), you'll get a lot of overhead from calling
by cygx 15y ago
One of the reasons for the performance difference is that you can't inline into the libc DLL blob: If you use qsort(), you'll get a lot of overhead from calling the comparison function.
If you use a custom quicksort implementation and put it into the same translation unit as the comparison function (or compile statically and use link-time optimizations with a sufficiently advanced compiler) you can get the same performance out of C.
- cageface 15y agoFunction call overhead is only one of the issues with the C version based on void pointers. Check out Stroustrup's keynote at Going Native 2012 for more details: http://channel9.msdn.com/Events/GoingNative/GoingNative-2012/Keynote-Bjarne-Stroustrup-Cpp11-Style http://channel9.msdn.com/Events/GoingNative/GoingNative-2012...