3 ms·
I don't agree with how you define "apples". I would define an apples to apples comparison as "How would a typical C developer write this test? How would a typ
by crusso 15y ago
I don't agree with how you define "apples".
I would define an apples to apples comparison as "How would a typical C developer write this test? How would a typical C++ developer write this test?"
A typical C developer would use a library function. A typical C++ developer would use the stl.
This was a great article for me because I am actually about to write some very performance intensive data manipulation code that will use sorting and other similar algorithms. I was thinking about doing it in C because I always mentally associate C with performance.
This article is a reminder to me that although I could eventually laboriously hand-tweak the C to be performant, there are things in C++ that will perform better than C without my even having to do much optimization, if any.
- veyron 15y agoFTA: By inlining C++ is able to run just the raw algorithm. On the opposite the C code has a number of indirections The typical C developer is aware of the deficiencies and would write a custom macro to do the sort (I have a whole macro library for many small functions) I agree that the language provides convenience, but the statement that sorting as a concept is faster in C++ than in C seems to be a stretch.