|
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/address@hidden
|
|
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/address@hidden
|
|
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/address@hidden
|
|
strlen
|
char[]
|
222
|
693
|
5410
|
5000000
|
1000000
|
|
string.size()
|
string
|
16
|
15
|
15
|
|
|
|
|
|
string assigment and addition (C vs. STL) - 1
|
|
http://groups.google.com/address@hidden
|
|
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/address@hidden
|
|
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/address@hidden
|
|
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/address@hidden
|
|
for-loop
|
vector<uint>
|
13
|
124
|
1225
|
|
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
|
|
|
list<uint>
|
9
|
78
|
773
|
|
for_each
|
set<uint>
|
12
|
104
|
1070
|
|
|
|
|
|
access to element
|
|
http://groups.google.com/address@hidden
|
|
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/address@hidden
|
|
templated function
|
int
|
16
|
5000000
|
1000000
|
|
ordinary function
|
int
|
5
|
|
templated function
|
string
|
344
|
345
|
345
|
|
ordinary function
|
string
|
344
|
345
|
350
|
|
|