Re: Generally, are the programs written by C++ slower than written by
C 10% ?
On Sep 3, 9:45 am, BGB <cr88...@hotmail.com> wrote:
On 9/2/2011 10:51 PM, Juha Nieminen wrote:
[...]
also, just how many people really use "qsort()" anyways?...
Not very many, because not very many people write applications
which might need it in C.
In earlier days, it was widely used.
IME, it is more often one of those largely forgotten functions (it is
there, but more often people write out their own sort logic manually).
That is, of course, complete bullshit. Any competent C
programmer will use it if he has to sort something.
(actually, it seems to be fairly common practice in C land for people to
largely ignore much of the standard library, and to write their own
logic for doing things).
Only among incompetent C programmers.
it is also not clear that std::string would be, in general, faster, and
having an O(1) ability to fetch the length may turn out to be moot if
most other operations tend towards being more expensive. not that
worrying about micro-optimizing string operations is usually all that
relevant though anyways.
from what I can gather from checking online (via Google), it seems where
people have tried testing, the performance differences have tended to be
negligible.
From my concrete experience, in several different applications
(including one where two separate teams implemented the same
thing, one in C and one in C++), when performance matters, C++
is usually a magnitude faster than C, if not more.
some other tests have apparently shown std::string operations to be
about 4x slower than C-style strings.
Never trust a benchmark you haven't rigged yourself. I would
have no problem writing a benchmark to prove whichever side I
wished.
In real applications, where performance matters, C++ is
significantly faster than C.
--
James Kanze