|
From: Ioannis V. <no...@ya...> - 2001-10-08 05:12:54
|
> -----Original Message----- > From: Ioannis Vranos [mailto:no...@ya...] > Sent: Monday, October 08, 2001 8:11 AM > To: Dev-C++ (dev...@li...) > Subject: C versus C++ > > > It is great you are interested for the reality of the things. > :) At first your code had some errors (for 100% ansi > standard) and omitions (you forgot #include <iostream> for > example) which i fixed. I did not dare to see your code and > think how exactly your algorithm work but the results showed > the C++ versions to be slower than C's. > > I attach you your code fixed as old.cpp. > > I wrote my code using the standard library sorting function > thus applying the same algorithm to both stuff. The code is > attached as > temp.cpp. > > The results are: > > C:\c>temp > begin: 2002 cend: 24885 cppend: 47558 > > char * sorting speed: 22883 std::string sorting speed: 22673 > > As you see the string speed here is smaller than char *. :) I made an expression mistake, these are timings and here string is *faster* than char *. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com * Alternative URL: http://run.to/noicys |