C/C++
Performance Tests
Using C/C++ Program
Perfometer
http://sourceforge.net/projects/cpp-perfometer
http://alexvn.freeservers.com/s1/perfometer.html
Environment
|
Windows 2000 Professional |
CYGWIN_NT-5.0 1.3.22(0.78/3/2) |
Intel(R) Celeron(R) CPU 1.70 GHz |
GNU gcc/g++ version 3.2 20020927 (prerelease) |
Compilation : No optimization |
Method |
Data Type |
Performance for size |
Unit of Measurement = milliseconds/per-times |
|||
10 |
100 |
1000 |
Iterations |
Per-times |
||
|
||||||
C-string initialization
|
||||||
http://groups.google.com/groups?selm=bcs4nc$lsdbq$1@ID-79865.news.dfncis.de |
||||||
init (char* x = y) |
char* |
4 |
4 |
4 |
5000000 |
1000000 |
init (char[] x = y) |
char[] |
5 |
232 |
402 |
||
|
||||||
|
||||||
string
initialization (C vs. STL) |
||||||
http://groups.google.com/groups?selm=bcs72j$ljpau$8@ID-79865.news.dfncis.de |
||||||
malloc & free |
char[] |
132 |
162 |
162 |
500000 |
100000 |
(malloc+strcpy) & free |
char[] |
137 |
179 |
274 |
||
(malloc+memset) & free |
char[] |
161 |
187 |
217 |
||
ctor & dtor |
string |
30 |
30 |
30 |
||
new & delete |
string |
223 |
274 |
892 |
||
|
||||||
|
||||||
string length (C vs. STL) |
||||||
http://groups.google.com/groups?selm=bcs72e$ljpau$7@ID-79865.news.dfncis.de |
||||||
strlen |
char[] |
222 |
693 |
5410 |
5000000 |
1000000 |
string.size() |
string |
16 |
15 |
15 |
||
|
||||||
|
||||||
string assignment and addition (C vs. STL) - 1 |
||||||
http://groups.google.com/groups?selm=bcs724$ljpau$6@ID-79865.news.dfncis.de |
||||||
strcpy |
char[] |
6 |
22 |
147 |
500000 |
100000 |
operator= |
string |
3 |
3 |
3 |
||
strcat (with cutting off) |
char[] |
10 |
26 |
152 |
||
operator+= (with erase) |
string |
100 |
112 |
184 |
||
operator+ (with erase) |
string |
234 |
234 |
508 |
||
|
||||||
|
||||||
string assignment and addition (C vs. STL) - 2 |
||||||
http://groups.google.com/groups?selm=bcs71t$ljpau$5@ID-79865.news.dfncis.de |
||||||
accumulated strcat (with cutting off) |
char[] |
1090 |
1194 |
1277 |
50000 |
10000 |
accumulated operator+= (with erase) |
string |
10 |
12 |
20 |
||
accumulated operator+ (with erase) |
string |
6311 |
6993 |
7280 |
||
|
||||||
|
||||||
find method vs.
find algorithm |
||||||
http://groups.google.com/groups?selm=bcs71j$ljpau$4@ID-79865.news.dfncis.de |
||||||
find algorithm |
vector<int> |
2 |
8 |
69 |
50000 |
10000 |
find algorithm |
list<int> |
2 |
15 |
142 |
||
find algorithm |
set<int> |
3 |
22 |
217 |
||
find method |
set<int> |
2 |
4 |
4 |
||
find method |
map<int> |
2 |
4 |
4 |
||
|
||||||
|
||||||
for-loop vs. for_each |
||||||
http://groups.google.com/groups?selm=bcs715$ljpau$3@ID-79865.news.dfncis.de |
||||||
for-loop |
vector<uint> |
13 |
124 |
1225 |
50000 |
10000 |
for-loop |
string |
14 |
120 |
1189 |
||
for-loop |
list<uint> |
15 |
133 |
1330 |
||
for-loop |
set<uint> |
13 |
129 |
1311 |
||
for_each |
vector<uint> |
10 |
92 |
915 |
||
for_each |
string |
10 |
93 |
917 |
||
for_each |
list<uint> |
9 |
78 |
773 |
||
for_each |
set<uint> |
12 |
104 |
1070 |
||
|
||||||
|
||||||
access to element |
||||||
http://groups.google.com/groups?selm=bcs70m$ljpau$2@ID-79865.news.dfncis.de |
||||||
operator[] |
char[] |
5 |
5 |
4 |
5000000 |
1000000 |
operator[] |
vector<char> |
90 |
90 |
90 |
||
operator[] |
string |
34 |
34 |
33 |
||
at method |
vector<char> |
222 |
222 |
223 |
||
at method |
string |
32 |
33 |
33 |
||
|
||||||
|
||||||
calling functions : templated vs. non-templated |
||||||
http://groups.google.com/groups?selm=bcs70m$ljpau$2@ID-79865.news.dfncis.de |
||||||
templated function |
int |
16 |
5000000 |
1000000 |
||
ordinary function |
int |
5 |
||||
templated function |
string |
344 |
345 |
345 |
||
ordinary function |
string |
344 |
345 |
350 |
||
|
http://mathforum.org/library/view/10978.html
07 Jule 2003