...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
In most cases boost::lexical_cast
is faster than scanf
, printf
,
std::stringstream
. For more detailed info you
can look at the tables below.
All the tests measure execution speed in milliseconds for 10000 iterations of the following code blocks:
Table 15.1. Tests source code
Test name |
Code |
---|---|
lexical_cast |
_out = boost::lexical_cast<OUTTYPE>(_in);
|
std::stringstream with construction |
std::stringstream ss; ss << _in; if (ss.fail()) throw std::logic_error(descr); ss >> _out; if (ss.fail()) throw std::logic_error(descr);
|
std::stringstream without construction |
ss << _in; // ss is an instance of std::stringstream if (ss.fail()) throw std::logic_error(descr); ss >> _out; if (ss.fail()) throw std::logic_error(descr); /* reseting std::stringstream to use it again */ ss.str(std::string()); ss.clear();
|
scanf/printf |
typename OUTTYPE::value_type buffer[500]; sprintf( (char*)buffer, conv, _in); _out = buffer;
|
Fastest results are highlitened with "!!! x !!!". Do not use this results to compare compilers, because tests were taken on different hardware.
Table 15.2. Performance Table ( Clang version 3.0 (tags/RELEASE_30/final))
From->To |
lexical_cast |
std::stringstream with construction |
std::stringstream without construction |
scanf/printf |
---|---|---|---|---|
string->char |
!!! <1 !!! |
169 |
9 |
10 |
string->signed char |
!!! <1 !!! |
108 |
8 |
10 |
string->unsigned char |
!!! <1 !!! |
103 |
9 |
10 |
string->int |
!!! 6 !!! |
117 |
24 |
24 |
string->short |
!!! 7 !!! |
115 |
20 |
24 |
string->long int |
!!! 7 !!! |
115 |
19 |
22 |
string->long long |
!!! 8 !!! |
116 |
21 |
23 |
string->unsigned int |
!!! 6 !!! |
121 |
18 |
23 |
string->unsigned short |
!!! 6 !!! |
116 |
19 |
22 |
string->unsigned long int |
!!! 7 !!! |
117 |
23 |
21 |
string->unsigned long long |
!!! 8 !!! |
118 |
19 |
34 |
string->float |
!!! 13 !!! |
201 |
55 |
41 |
string->double |
!!! 14 !!! |
151 |
54 |
41 |
string->long double |
195 |
231 |
67 |
!!! 42 !!! |
string->array<char, 50> |
!!! <1 !!! |
121 |
18 |
12 |
string->string |
!!! 1 !!! |
124 |
27 |
--- |
string->container::string |
!!! 3 !!! |
114 |
25 |
--- |
string->char |
7 |
111 |
25 |
!!! 7 !!! |
string->signed char |
!!! 6 !!! |
112 |
30 |
26 |
string->unsigned char |
!!! 6 !!! |
113 |
25 |
24 |
int->string |
!!! 12 !!! |
126 |
36 |
21 |
short->string |
!!! 11 !!! |
135 |
30 |
21 |
long int->string |
!!! 11 !!! |
128 |
28 |
21 |
long long->string |
!!! 12 !!! |
126 |
32 |
24 |
unsigned int->string |
!!! 11 !!! |
131 |
36 |
22 |
unsigned short->string |
!!! 11 !!! |
130 |
28 |
22 |
unsigned long int->string |
!!! 11 !!! |
130 |
36 |
22 |
unsigned long long->string |
!!! 11 !!! |
127 |
43 |
25 |
float->string |
53 |
190 |
83 |
!!! 41 !!! |
double->string |
59 |
197 |
82 |
!!! 44 !!! |
long double->string |
118 |
229 |
101 |
!!! 44 !!! |
char*->char |
!!! 1 !!! |
105 |
9 |
9 |
char*->signed char |
!!! 1 !!! |
107 |
10 |
10 |
char*->unsigned char |
!!! 1 !!! |
106 |
9 |
11 |
char*->int |
!!! 7 !!! |
149 |
25 |
24 |
char*->short |
!!! 7 !!! |
118 |
20 |
22 |
char*->long int |
!!! 9 !!! |
117 |
20 |
28 |
char*->long long |
!!! 9 !!! |
128 |
23 |
29 |
char*->unsigned int |
!!! 7 !!! |
120 |
19 |
23 |
char*->unsigned short |
!!! 7 !!! |
125 |
20 |
22 |
char*->unsigned long int |
!!! 8 !!! |
125 |
21 |
24 |
char*->unsigned long long |
!!! 8 !!! |
130 |
19 |
22 |
char*->float |
!!! 14 !!! |
162 |
56 |
41 |
char*->double |
!!! 16 !!! |
151 |
54 |
39 |
char*->long double |
111 |
176 |
58 |
!!! 42 !!! |
char*->array<char, 50> |
!!! 1 !!! |
116 |
20 |
17 |
char*->string |
!!! 8 !!! |
125 |
27 |
--- |
char*->container::string |
!!! 2 !!! |
115 |
26 |
--- |
unsigned char*->char |
!!! 1 !!! |
101 |
9 |
9 |
unsigned char*->signed char |
!!! 1 !!! |
104 |
9 |
11 |
unsigned char*->unsigned char |
!!! 1 !!! |
103 |
9 |
13 |
unsigned char*->int |
!!! 8 !!! |
116 |
20 |
24 |
unsigned char*->short |
!!! 7 !!! |
121 |
20 |
26 |
unsigned char*->long int |
!!! 8 !!! |
118 |
20 |
22 |
unsigned char*->long long |
!!! 8 !!! |
122 |
20 |
23 |
unsigned char*->unsigned int |
!!! 6 !!! |
119 |
22 |
23 |
unsigned char*->unsigned short |
!!! 7 !!! |
122 |
20 |
22 |
unsigned char*->unsigned long int |
!!! 8 !!! |
125 |
21 |
22 |
unsigned char*->unsigned long long |
!!! 8 !!! |
122 |
19 |
25 |
unsigned char*->float |
!!! 14 !!! |
162 |
62 |
37 |
unsigned char*->double |
!!! 15 !!! |
151 |
58 |
39 |
unsigned char*->long double |
116 |
156 |
58 |
!!! 42 !!! |
unsigned char*->array<char, 50> |
!!! 1 !!! |
122 |
19 |
15 |
unsigned char*->string |
!!! 8 !!! |
124 |
27 |
--- |
unsigned char*->container::string |
!!! 4 !!! |
119 |
25 |
--- |
signed char*->char |
!!! 1 !!! |
107 |
9 |
9 |
signed char*->signed char |
!!! 1 !!! |
108 |
10 |
11 |
signed char*->unsigned char |
!!! 1 !!! |
106 |
9 |
11 |
signed char*->int |
!!! 7 !!! |
122 |
21 |
22 |
signed char*->short |
!!! 7 !!! |
126 |
20 |
22 |
signed char*->long int |
!!! 8 !!! |
119 |
20 |
23 |
signed char*->long long |
!!! 8 !!! |
119 |
21 |
26 |
signed char*->unsigned int |
!!! 6 !!! |
124 |
18 |
22 |
signed char*->unsigned short |
!!! 7 !!! |
124 |
21 |
23 |
signed char*->unsigned long int |
!!! 8 !!! |
121 |
24 |
23 |
signed char*->unsigned long long |
!!! 8 !!! |
122 |
20 |
22 |
signed char*->float |
!!! 14 !!! |
167 |
56 |
37 |
signed char*->double |
!!! 14 !!! |
162 |
53 |
40 |
signed char*->long double |
110 |
152 |
56 |
!!! 42 !!! |
signed char*->array<char, 50> |
!!! 1 !!! |
117 |
19 |
12 |
signed char*->string |
!!! 8 !!! |
132 |
27 |
--- |
signed char*->container::string |
!!! 4 !!! |
116 |
26 |
--- |
iterator_range<char*>->char |
!!! <1 !!! |
112 |
14 |
9 |
iterator_range<char*>->signed char |
!!! <1 !!! |
107 |
13 |
10 |
iterator_range<char*>->unsigned char |
!!! <1 !!! |
145 |
15 |
10 |
iterator_range<char*>->int |
!!! 6 !!! |
119 |
22 |
23 |
iterator_range<char*>->short |
!!! 6 !!! |
115 |
22 |
23 |
iterator_range<char*>->long int |
!!! 7 !!! |
115 |
25 |
22 |
iterator_range<char*>->long long |
!!! 7 !!! |
117 |
21 |
23 |
iterator_range<char*>->unsigned int |
!!! 6 !!! |
118 |
22 |
22 |
iterator_range<char*>->unsigned short |
!!! 6 !!! |
117 |
24 |
22 |
iterator_range<char*>->unsigned long int |
!!! 7 !!! |
124 |
25 |
22 |
iterator_range<char*>->unsigned long long |
!!! 7 !!! |
119 |
22 |
22 |
iterator_range<char*>->float |
!!! 13 !!! |
159 |
42 |
41 |
iterator_range<char*>->double |
!!! 14 !!! |
152 |
40 |
40 |
iterator_range<char*>->long double |
113 |
155 |
58 |
!!! 54 !!! |
iterator_range<char*>->array<char, 50> |
!!! <1 !!! |
127 |
23 |
13 |
iterator_range<char*>->string |
!!! 7 !!! |
132 |
30 |
--- |
iterator_range<char*>->container::string |
!!! 3 !!! |
122 |
24 |
--- |
array<char, 50>->char |
!!! <1 !!! |
110 |
9 |
10 |
array<char, 50>->signed char |
!!! <1 !!! |
119 |
9 |
13 |
array<char, 50>->unsigned char |
!!! <1 !!! |
106 |
13 |
11 |
array<char, 50>->int |
!!! 6 !!! |
131 |
21 |
22 |
array<char, 50>->short |
!!! 7 !!! |
119 |
22 |
28 |
array<char, 50>->long int |
!!! 8 !!! |
133 |
21 |
26 |
array<char, 50>->long long |
!!! 8 !!! |
115 |
22 |
23 |
array<char, 50>->unsigned int |
!!! 6 !!! |
118 |
18 |
22 |
array<char, 50>->unsigned short |
!!! 7 !!! |
119 |
19 |
22 |
array<char, 50>->unsigned long int |
!!! 7 !!! |
118 |
23 |
21 |
array<char, 50>->unsigned long long |
!!! 7 !!! |
117 |
20 |
22 |
array<char, 50>->float |
!!! 15 !!! |
156 |
53 |
36 |
array<char, 50>->double |
!!! 15 !!! |
148 |
55 |
39 |
array<char, 50>->long double |
110 |
150 |
56 |
!!! 41 !!! |
array<char, 50>->array<char, 50> |
!!! <1 !!! |
117 |
19 |
12 |
array<char, 50>->string |
!!! 7 !!! |
124 |
26 |
--- |
array<char, 50>->container::string |
!!! 4 !!! |
115 |
26 |
--- |
int->int |
!!! <1 !!! |
117 |
24 |
--- |
float->double |
!!! <1 !!! |
245 |
125 |
--- |
char->signed char |
!!! <1 !!! |
100 |
9 |
--- |
Table 15.3. Performance Table ( GNU C++ version 4.6.3)
From->To |
lexical_cast |
std::stringstream with construction |
std::stringstream without construction |
scanf/printf |
---|---|---|---|---|
string->char |
!!! <1 !!! |
142 |
10 |
18 |
string->signed char |
!!! <1 !!! |
111 |
8 |
10 |
string->unsigned char |
!!! <1 !!! |
101 |
8 |
10 |
string->int |
!!! 7 !!! |
110 |
20 |
24 |
string->short |
!!! 6 !!! |
109 |
20 |
25 |
string->long int |
!!! 7 !!! |
113 |
19 |
24 |
string->long long |
!!! 7 !!! |
116 |
24 |
23 |
string->unsigned int |
!!! 6 !!! |
110 |
19 |
23 |
string->unsigned short |
!!! 5 !!! |
116 |
18 |
23 |
string->unsigned long int |
!!! 7 !!! |
111 |
22 |
23 |
string->unsigned long long |
!!! 7 !!! |
108 |
20 |
22 |
string->float |
!!! 11 !!! |
161 |
54 |
38 |
string->double |
!!! 11 !!! |
146 |
56 |
41 |
string->long double |
113 |
151 |
59 |
!!! 43 !!! |
string->array<char, 50> |
!!! <1 !!! |
107 |
18 |
14 |
string->string |
!!! 2 !!! |
127 |
24 |
--- |
string->container::string |
!!! 3 !!! |
142 |
26 |
--- |
string->char |
!!! 7 !!! |
110 |
23 |
17 |
string->signed char |
!!! 7 !!! |
114 |
23 |
24 |
string->unsigned char |
!!! 7 !!! |
110 |
25 |
24 |
int->string |
!!! 12 !!! |
127 |
31 |
22 |
short->string |
!!! 13 !!! |
129 |
31 |
22 |
long int->string |
!!! 12 !!! |
125 |
30 |
22 |
long long->string |
!!! 13 !!! |
127 |
34 |
24 |
unsigned int->string |
!!! 13 !!! |
127 |
27 |
21 |
unsigned short->string |
!!! 12 !!! |
127 |
28 |
22 |
unsigned long int->string |
!!! 12 !!! |
131 |
27 |
22 |
unsigned long long->string |
!!! 12 !!! |
125 |
28 |
24 |
float->string |
51 |
200 |
81 |
!!! 40 !!! |
double->string |
56 |
194 |
82 |
!!! 48 !!! |
long double->string |
65 |
220 |
82 |
!!! 41 !!! |
char*->char |
!!! <1 !!! |
104 |
10 |
9 |
char*->signed char |
!!! <1 !!! |
101 |
10 |
11 |
char*->unsigned char |
!!! <1 !!! |
99 |
10 |
12 |
char*->int |
!!! 6 !!! |
112 |
23 |
24 |
char*->short |
!!! 6 !!! |
115 |
21 |
23 |
char*->long int |
!!! 8 !!! |
111 |
21 |
24 |
char*->long long |
!!! 9 !!! |
112 |
21 |
30 |
char*->unsigned int |
!!! 7 !!! |
112 |
22 |
24 |
char*->unsigned short |
!!! 6 !!! |
119 |
19 |
23 |
char*->unsigned long int |
!!! 7 !!! |
115 |
22 |
23 |
char*->unsigned long long |
!!! 7 !!! |
115 |
20 |
23 |
char*->float |
!!! 12 !!! |
153 |
54 |
39 |
char*->double |
!!! 12 !!! |
153 |
61 |
41 |
char*->long double |
108 |
160 |
61 |
!!! 49 !!! |
char*->array<char, 50> |
!!! <1 !!! |
107 |
20 |
14 |
char*->string |
!!! 7 !!! |
123 |
26 |
--- |
char*->container::string |
!!! 2 !!! |
121 |
24 |
--- |
unsigned char*->char |
!!! <1 !!! |
97 |
10 |
9 |
unsigned char*->signed char |
!!! <1 !!! |
98 |
10 |
12 |
unsigned char*->unsigned char |
!!! <1 !!! |
99 |
11 |
12 |
unsigned char*->int |
!!! 6 !!! |
112 |
22 |
24 |
unsigned char*->short |
!!! 10 !!! |
111 |
24 |
24 |
unsigned char*->long int |
!!! 8 !!! |
110 |
23 |
24 |
unsigned char*->long long |
!!! 9 !!! |
115 |
21 |
25 |
unsigned char*->unsigned int |
!!! 6 !!! |
111 |
24 |
23 |
unsigned char*->unsigned short |
!!! 6 !!! |
118 |
19 |
23 |
unsigned char*->unsigned long int |
!!! 8 !!! |
112 |
21 |
23 |
unsigned char*->unsigned long long |
!!! 13 !!! |
109 |
20 |
23 |
unsigned char*->float |
!!! 12 !!! |
154 |
56 |
39 |
unsigned char*->double |
!!! 17 !!! |
150 |
58 |
41 |
unsigned char*->long double |
108 |
149 |
68 |
!!! 43 !!! |
unsigned char*->array<char, 50> |
!!! 1 !!! |
107 |
19 |
15 |
unsigned char*->string |
!!! 8 !!! |
124 |
26 |
--- |
unsigned char*->container::string |
!!! 4 !!! |
121 |
24 |
--- |
signed char*->char |
!!! <1 !!! |
99 |
10 |
9 |
signed char*->signed char |
!!! <1 !!! |
99 |
10 |
10 |
signed char*->unsigned char |
!!! <1 !!! |
99 |
10 |
12 |
signed char*->int |
!!! 6 !!! |
113 |
28 |
24 |
signed char*->short |
!!! 6 !!! |
110 |
21 |
25 |
signed char*->long int |
!!! 8 !!! |
110 |
21 |
24 |
signed char*->long long |
!!! 9 !!! |
116 |
21 |
24 |
signed char*->unsigned int |
!!! 7 !!! |
114 |
21 |
23 |
signed char*->unsigned short |
!!! 6 !!! |
116 |
20 |
23 |
signed char*->unsigned long int |
!!! 8 !!! |
113 |
27 |
23 |
signed char*->unsigned long long |
!!! 8 !!! |
110 |
20 |
23 |
signed char*->float |
!!! 12 !!! |
155 |
53 |
44 |
signed char*->double |
!!! 13 !!! |
150 |
60 |
42 |
signed char*->long double |
108 |
151 |
62 |
!!! 44 !!! |
signed char*->array<char, 50> |
!!! 1 !!! |
107 |
19 |
15 |
signed char*->string |
!!! 8 !!! |
124 |
26 |
--- |
signed char*->container::string |
!!! 4 !!! |
121 |
24 |
--- |
iterator_range<char*>->char |
!!! <1 !!! |
103 |
14 |
10 |
iterator_range<char*>->signed char |
!!! <1 !!! |
102 |
15 |
12 |
iterator_range<char*>->unsigned char |
!!! <1 !!! |
102 |
14 |
12 |
iterator_range<char*>->int |
!!! 6 !!! |
115 |
23 |
24 |
iterator_range<char*>->short |
!!! 5 !!! |
110 |
22 |
24 |
iterator_range<char*>->long int |
!!! 7 !!! |
109 |
22 |
29 |
iterator_range<char*>->long long |
!!! 7 !!! |
111 |
24 |
28 |
iterator_range<char*>->unsigned int |
!!! 6 !!! |
114 |
22 |
23 |
iterator_range<char*>->unsigned short |
!!! 5 !!! |
115 |
20 |
22 |
iterator_range<char*>->unsigned long int |
!!! 7 !!! |
123 |
26 |
23 |
iterator_range<char*>->unsigned long long |
!!! 7 !!! |
110 |
23 |
24 |
iterator_range<char*>->float |
!!! 11 !!! |
153 |
38 |
38 |
iterator_range<char*>->double |
!!! 11 !!! |
140 |
43 |
40 |
iterator_range<char*>->long double |
108 |
147 |
!!! 41 !!! |
46 |
iterator_range<char*>->array<char, 50> |
!!! <1 !!! |
109 |
22 |
15 |
iterator_range<char*>->string |
!!! 8 !!! |
122 |
29 |
--- |
iterator_range<char*>->container::string |
!!! 3 !!! |
117 |
23 |
--- |
array<char, 50>->char |
!!! <1 !!! |
98 |
10 |
9 |
array<char, 50>->signed char |
!!! <1 !!! |
99 |
9 |
12 |
array<char, 50>->unsigned char |
!!! <1 !!! |
102 |
9 |
12 |
array<char, 50>->int |
!!! 6 !!! |
119 |
23 |
23 |
array<char, 50>->short |
!!! 6 !!! |
111 |
21 |
26 |
array<char, 50>->long int |
!!! 7 !!! |
115 |
20 |
28 |
array<char, 50>->long long |
!!! 9 !!! |
110 |
21 |
26 |
array<char, 50>->unsigned int |
!!! 6 !!! |
115 |
22 |
23 |
array<char, 50>->unsigned short |
!!! 6 !!! |
115 |
19 |
23 |
array<char, 50>->unsigned long int |
!!! 7 !!! |
118 |
23 |
23 |
array<char, 50>->unsigned long long |
!!! 7 !!! |
109 |
20 |
24 |
array<char, 50>->float |
!!! 12 !!! |
160 |
53 |
38 |
array<char, 50>->double |
!!! 11 !!! |
147 |
57 |
41 |
array<char, 50>->long double |
109 |
154 |
59 |
!!! 42 !!! |
array<char, 50>->array<char, 50> |
!!! 1 !!! |
105 |
19 |
14 |
array<char, 50>->string |
!!! 8 !!! |
129 |
26 |
--- |
array<char, 50>->container::string |
!!! 4 !!! |
116 |
25 |
--- |
int->int |
!!! <1 !!! |
118 |
24 |
--- |
float->double |
!!! <1 !!! |
242 |
132 |
--- |
char->signed char |
!!! <1 !!! |
94 |
8 |
--- |
Table 15.4. Performance Table ( GNU C++ version 4.5.3)
From->To |
lexical_cast |
std::stringstream with construction |
std::stringstream without construction |
scanf/printf |
---|---|---|---|---|
string->char |
!!! <1 !!! |
153 |
15 |
9 |
string->signed char |
!!! <1 !!! |
134 |
8 |
10 |
string->unsigned char |
!!! <1 !!! |
97 |
8 |
14 |
string->int |
!!! 7 !!! |
115 |
22 |
22 |
string->short |
!!! 5 !!! |
112 |
19 |
21 |
string->long int |
!!! 7 !!! |
110 |
19 |
24 |
string->long long |
!!! 7 !!! |
115 |
21 |
23 |
string->unsigned int |
!!! 6 !!! |
113 |
20 |
23 |
string->unsigned short |
!!! 5 !!! |
116 |
18 |
23 |
string->unsigned long int |
!!! 7 !!! |
111 |
20 |
23 |
string->unsigned long long |
!!! 7 !!! |
115 |
18 |
23 |
string->float |
!!! 14 !!! |
153 |
55 |
38 |
string->double |
!!! 11 !!! |
151 |
60 |
38 |
string->long double |
107 |
151 |
59 |
!!! 44 !!! |
string->array<char, 50> |
!!! <1 !!! |
107 |
18 |
12 |
string->string |
!!! 2 !!! |
129 |
49 |
--- |
string->container::string |
!!! 9 !!! |
199 |
22 |
--- |
string->char |
!!! 7 !!! |
114 |
27 |
16 |
string->signed char |
!!! 7 !!! |
116 |
32 |
23 |
string->unsigned char |
!!! 7 !!! |
114 |
27 |
22 |
int->string |
!!! 11 !!! |
125 |
31 |
21 |
short->string |
!!! 11 !!! |
126 |
33 |
21 |
long int->string |
!!! 11 !!! |
126 |
32 |
22 |
long long->string |
!!! 11 !!! |
118 |
30 |
23 |
unsigned int->string |
!!! 11 !!! |
125 |
31 |
20 |
unsigned short->string |
!!! 12 !!! |
128 |
30 |
21 |
unsigned long int->string |
!!! 11 !!! |
131 |
30 |
21 |
unsigned long long->string |
!!! 11 !!! |
127 |
32 |
23 |
float->string |
49 |
197 |
92 |
!!! 39 !!! |
double->string |
56 |
195 |
80 |
!!! 43 !!! |
long double->string |
60 |
222 |
88 |
!!! 42 !!! |
char*->char |
!!! <1 !!! |
100 |
10 |
9 |
char*->signed char |
!!! <1 !!! |
99 |
10 |
10 |
char*->unsigned char |
!!! <1 !!! |
106 |
10 |
10 |
char*->int |
!!! 7 !!! |
113 |
23 |
22 |
char*->short |
!!! 6 !!! |
113 |
21 |
23 |
char*->long int |
!!! 8 !!! |
116 |
21 |
23 |
char*->long long |
!!! 8 !!! |
115 |
21 |
21 |
char*->unsigned int |
!!! 6 !!! |
114 |
25 |
22 |
char*->unsigned short |
!!! 6 !!! |
119 |
20 |
23 |
char*->unsigned long int |
!!! 8 !!! |
114 |
23 |
23 |
char*->unsigned long long |
!!! 7 !!! |
111 |
20 |
24 |
char*->float |
!!! 16 !!! |
154 |
54 |
38 |
char*->double |
!!! 12 !!! |
149 |
59 |
40 |
char*->long double |
107 |
166 |
62 |
!!! 44 !!! |
char*->array<char, 50> |
!!! 1 !!! |
108 |
20 |
12 |
char*->string |
!!! 8 !!! |
125 |
28 |
--- |
char*->container::string |
!!! 2 !!! |
123 |
24 |
--- |
unsigned char*->char |
!!! <1 !!! |
104 |
11 |
9 |
unsigned char*->signed char |
!!! <1 !!! |
106 |
10 |
10 |
unsigned char*->unsigned char |
!!! <1 !!! |
101 |
10 |
10 |
unsigned char*->int |
!!! 7 !!! |
117 |
22 |
24 |
unsigned char*->short |
!!! 6 !!! |
111 |
26 |
22 |
unsigned char*->long int |
!!! 8 !!! |
111 |
23 |
23 |
unsigned char*->long long |
!!! 8 !!! |
114 |
21 |
23 |
unsigned char*->unsigned int |
!!! 7 !!! |
115 |
20 |
25 |
unsigned char*->unsigned short |
!!! 6 !!! |
113 |
20 |
22 |
unsigned char*->unsigned long int |
!!! 8 !!! |
115 |
25 |
24 |
unsigned char*->unsigned long long |
!!! 7 !!! |
113 |
25 |
25 |
unsigned char*->float |
!!! 16 !!! |
158 |
55 |
38 |
unsigned char*->double |
!!! 12 !!! |
155 |
62 |
40 |
unsigned char*->long double |
108 |
153 |
60 |
!!! 41 !!! |
unsigned char*->array<char, 50> |
!!! 1 !!! |
111 |
19 |
12 |
unsigned char*->string |
!!! 8 !!! |
125 |
30 |
--- |
unsigned char*->container::string |
!!! 4 !!! |
121 |
23 |
--- |
signed char*->char |
!!! <1 !!! |
98 |
14 |
9 |
signed char*->signed char |
!!! <1 !!! |
98 |
11 |
10 |
signed char*->unsigned char |
!!! <1 !!! |
99 |
10 |
10 |
signed char*->int |
!!! 7 !!! |
111 |
22 |
24 |
signed char*->short |
!!! 6 !!! |
123 |
22 |
23 |
signed char*->long int |
!!! 8 !!! |
112 |
21 |
23 |
signed char*->long long |
!!! 8 !!! |
114 |
24 |
24 |
signed char*->unsigned int |
!!! 6 !!! |
114 |
19 |
22 |
signed char*->unsigned short |
!!! 6 !!! |
112 |
21 |
24 |
signed char*->unsigned long int |
!!! 8 !!! |
114 |
23 |
22 |
signed char*->unsigned long long |
!!! 8 !!! |
116 |
22 |
24 |
signed char*->float |
!!! 16 !!! |
156 |
55 |
38 |
signed char*->double |
!!! 12 !!! |
151 |
59 |
39 |
signed char*->long double |
111 |
159 |
60 |
!!! 44 !!! |
signed char*->array<char, 50> |
!!! 1 !!! |
107 |
24 |
12 |
signed char*->string |
!!! 8 !!! |
122 |
28 |
--- |
signed char*->container::string |
!!! 4 !!! |
122 |
23 |
--- |
iterator_range<char*>->char |
!!! <1 !!! |
103 |
13 |
10 |
iterator_range<char*>->signed char |
!!! <1 !!! |
103 |
13 |
10 |
iterator_range<char*>->unsigned char |
!!! <1 !!! |
104 |
14 |
10 |
iterator_range<char*>->int |
!!! 6 !!! |
115 |
23 |
24 |
iterator_range<char*>->short |
!!! 7 !!! |
111 |
21 |
24 |
iterator_range<char*>->long int |
!!! 7 !!! |
108 |
21 |
23 |
iterator_range<char*>->long long |
!!! 7 !!! |
114 |
24 |
23 |
iterator_range<char*>->unsigned int |
!!! 6 !!! |
111 |
22 |
23 |
iterator_range<char*>->unsigned short |
!!! 5 !!! |
114 |
20 |
23 |
iterator_range<char*>->unsigned long int |
!!! 7 !!! |
119 |
25 |
24 |
iterator_range<char*>->unsigned long long |
!!! 7 !!! |
110 |
20 |
24 |
iterator_range<char*>->float |
!!! 15 !!! |
148 |
38 |
40 |
iterator_range<char*>->double |
!!! 10 !!! |
146 |
41 |
40 |
iterator_range<char*>->long double |
103 |
138 |
!!! 39 !!! |
42 |
iterator_range<char*>->array<char, 50> |
!!! <1 !!! |
109 |
22 |
13 |
iterator_range<char*>->string |
!!! 7 !!! |
121 |
32 |
--- |
iterator_range<char*>->container::string |
!!! 3 !!! |
120 |
24 |
--- |
array<char, 50>->char |
!!! <1 !!! |
102 |
9 |
9 |
array<char, 50>->signed char |
!!! <1 !!! |
97 |
9 |
10 |
array<char, 50>->unsigned char |
!!! <1 !!! |
99 |
9 |
10 |
array<char, 50>->int |
!!! 7 !!! |
114 |
22 |
23 |
array<char, 50>->short |
!!! 6 !!! |
116 |
21 |
23 |
array<char, 50>->long int |
!!! 7 !!! |
109 |
20 |
23 |
array<char, 50>->long long |
!!! 7 !!! |
114 |
21 |
23 |
array<char, 50>->unsigned int |
!!! 7 !!! |
119 |
20 |
25 |
array<char, 50>->unsigned short |
!!! 6 !!! |
120 |
20 |
23 |
array<char, 50>->unsigned long int |
!!! 7 !!! |
113 |
20 |
21 |
array<char, 50>->unsigned long long |
!!! 7 !!! |
112 |
20 |
24 |
array<char, 50>->float |
!!! 16 !!! |
155 |
57 |
38 |
array<char, 50>->double |
!!! 11 !!! |
152 |
59 |
42 |
array<char, 50>->long double |
107 |
152 |
60 |
!!! 41 !!! |
array<char, 50>->array<char, 50> |
!!! 1 !!! |
111 |
20 |
12 |
array<char, 50>->string |
!!! 8 !!! |
123 |
36 |
--- |
array<char, 50>->container::string |
!!! 4 !!! |
128 |
23 |
--- |
int->int |
!!! <1 !!! |
118 |
26 |
--- |
float->double |
!!! <1 !!! |
233 |
120 |
--- |
char->signed char |
!!! <1 !!! |
97 |
8 |
--- |
Table 15.5. Performance Table ( GNU C++ version 4.4.7)
From->To |
lexical_cast |
std::stringstream with construction |
std::stringstream without construction |
scanf/printf |
---|---|---|---|---|
string->char |
!!! <1 !!! |
111 |
8 |
9 |
string->signed char |
!!! <1 !!! |
100 |
8 |
10 |
string->unsigned char |
!!! <1 !!! |
102 |
8 |
11 |
string->int |
!!! 6 !!! |
114 |
21 |
23 |
string->short |
!!! 5 !!! |
120 |
21 |
29 |
string->long int |
!!! 7 !!! |
114 |
22 |
26 |
string->long long |
!!! 7 !!! |
118 |
21 |
23 |
string->unsigned int |
!!! 7 !!! |
115 |
21 |
23 |
string->unsigned short |
!!! 5 !!! |
119 |
18 |
22 |
string->unsigned long int |
!!! 7 !!! |
115 |
20 |
23 |
string->unsigned long long |
!!! 9 !!! |
116 |
26 |
24 |
string->float |
!!! 12 !!! |
165 |
53 |
40 |
string->double |
!!! 12 !!! |
154 |
54 |
40 |
string->long double |
112 |
148 |
61 |
!!! 45 !!! |
string->array<char, 50> |
!!! <1 !!! |
120 |
19 |
14 |
string->string |
!!! 2 !!! |
141 |
55 |
--- |
string->container::string |
!!! 2 !!! |
164 |
36 |
--- |
string->char |
!!! 7 !!! |
161 |
24 |
18 |
string->signed char |
!!! 6 !!! |
109 |
25 |
24 |
string->unsigned char |
!!! 6 !!! |
109 |
25 |
25 |
int->string |
!!! 11 !!! |
128 |
32 |
23 |
short->string |
!!! 12 !!! |
136 |
54 |
34 |
long int->string |
!!! 15 !!! |
187 |
41 |
23 |
long long->string |
!!! 11 !!! |
128 |
30 |
29 |
unsigned int->string |
!!! 13 !!! |
124 |
29 |
23 |
unsigned short->string |
!!! 11 !!! |
128 |
30 |
22 |
unsigned long int->string |
!!! 11 !!! |
131 |
30 |
22 |
unsigned long long->string |
!!! 11 !!! |
133 |
33 |
29 |
float->string |
52 |
187 |
90 |
!!! 39 !!! |
double->string |
58 |
190 |
86 |
!!! 45 !!! |
long double->string |
70 |
218 |
88 |
!!! 47 !!! |
char*->char |
!!! <1 !!! |
99 |
11 |
9 |
char*->signed char |
!!! <1 !!! |
99 |
11 |
10 |
char*->unsigned char |
!!! <1 !!! |
100 |
12 |
10 |
char*->int |
!!! 6 !!! |
117 |
23 |
21 |
char*->short |
!!! 6 !!! |
115 |
28 |
23 |
char*->long int |
!!! 7 !!! |
119 |
22 |
24 |
char*->long long |
!!! 7 !!! |
114 |
23 |
22 |
char*->unsigned int |
!!! 6 !!! |
113 |
21 |
21 |
char*->unsigned short |
!!! 6 !!! |
120 |
21 |
21 |
char*->unsigned long int |
!!! 7 !!! |
117 |
25 |
23 |
char*->unsigned long long |
!!! 7 !!! |
119 |
23 |
21 |
char*->float |
!!! 13 !!! |
160 |
61 |
36 |
char*->double |
!!! 13 !!! |
152 |
54 |
40 |
char*->long double |
116 |
173 |
58 |
!!! 43 !!! |
char*->array<char, 50> |
!!! 1 !!! |
121 |
20 |
12 |
char*->string |
!!! 7 !!! |
126 |
29 |
--- |
char*->container::string |
!!! 2 !!! |
119 |
27 |
--- |
unsigned char*->char |
!!! <1 !!! |
96 |
12 |
9 |
unsigned char*->signed char |
!!! <1 !!! |
95 |
11 |
12 |
unsigned char*->unsigned char |
!!! <1 !!! |
95 |
12 |
12 |
unsigned char*->int |
!!! 6 !!! |
113 |
27 |
24 |
unsigned char*->short |
!!! 6 !!! |
120 |
23 |
21 |
unsigned char*->long int |
!!! 7 !!! |
114 |
22 |
23 |
unsigned char*->long long |
!!! 7 !!! |
114 |
23 |
23 |
unsigned char*->unsigned int |
!!! 6 !!! |
115 |
23 |
23 |
unsigned char*->unsigned short |
!!! 6 !!! |
120 |
21 |
23 |
unsigned char*->unsigned long int |
!!! 7 !!! |
117 |
23 |
21 |
unsigned char*->unsigned long long |
!!! 7 !!! |
121 |
23 |
21 |
unsigned char*->float |
!!! 12 !!! |
161 |
58 |
39 |
unsigned char*->double |
!!! 13 !!! |
153 |
54 |
38 |
unsigned char*->long double |
110 |
150 |
62 |
!!! 43 !!! |
unsigned char*->array<char, 50> |
!!! 1 !!! |
113 |
20 |
12 |
unsigned char*->string |
!!! 8 !!! |
124 |
30 |
--- |
unsigned char*->container::string |
!!! 3 !!! |
118 |
27 |
--- |
signed char*->char |
!!! <1 !!! |
99 |
11 |
9 |
signed char*->signed char |
!!! <1 !!! |
102 |
12 |
10 |
signed char*->unsigned char |
!!! <1 !!! |
99 |
12 |
10 |
signed char*->int |
!!! 6 !!! |
114 |
30 |
23 |
signed char*->short |
!!! 6 !!! |
118 |
23 |
23 |
signed char*->long int |
!!! 7 !!! |
119 |
22 |
21 |
signed char*->long long |
!!! 7 !!! |
114 |
23 |
26 |
signed char*->unsigned int |
!!! 6 !!! |
114 |
26 |
23 |
signed char*->unsigned short |
!!! 6 !!! |
121 |
22 |
23 |
signed char*->unsigned long int |
!!! 7 !!! |
126 |
23 |
21 |
signed char*->unsigned long long |
!!! 7 !!! |
114 |
22 |
21 |
signed char*->float |
!!! 12 !!! |
163 |
57 |
39 |
signed char*->double |
!!! 13 !!! |
156 |
53 |
40 |
signed char*->long double |
112 |
156 |
56 |
!!! 42 !!! |
signed char*->array<char, 50> |
!!! 1 !!! |
117 |
20 |
12 |
signed char*->string |
!!! 8 !!! |
127 |
28 |
--- |
signed char*->container::string |
!!! 4 !!! |
112 |
27 |
--- |
iterator_range<char*>->char |
!!! <1 !!! |
103 |
14 |
9 |
iterator_range<char*>->signed char |
!!! <1 !!! |
104 |
16 |
10 |
iterator_range<char*>->unsigned char |
!!! <1 !!! |
103 |
16 |
10 |
iterator_range<char*>->int |
!!! 6 !!! |
121 |
22 |
21 |
iterator_range<char*>->short |
!!! 7 !!! |
112 |
23 |
23 |
iterator_range<char*>->long int |
!!! 7 !!! |
115 |
24 |
23 |
iterator_range<char*>->long long |
!!! 7 !!! |
113 |
24 |
23 |
iterator_range<char*>->unsigned int |
!!! 6 !!! |
117 |
26 |
23 |
iterator_range<char*>->unsigned short |
!!! 5 !!! |
120 |
20 |
23 |
iterator_range<char*>->unsigned long int |
!!! 7 !!! |
124 |
28 |
21 |
iterator_range<char*>->unsigned long long |
!!! 7 !!! |
113 |
22 |
21 |
iterator_range<char*>->float |
!!! 11 !!! |
190 |
58 |
63 |
iterator_range<char*>->double |
!!! 20 !!! |
194 |
44 |
39 |
iterator_range<char*>->long double |
116 |
145 |
46 |
!!! 44 !!! |
iterator_range<char*>->array<char, 50> |
!!! <1 !!! |
116 |
23 |
15 |
iterator_range<char*>->string |
!!! 7 !!! |
127 |
33 |
--- |
iterator_range<char*>->container::string |
!!! 3 !!! |
112 |
24 |
--- |
array<char, 50>->char |
!!! <1 !!! |
98 |
11 |
10 |
array<char, 50>->signed char |
!!! <1 !!! |
99 |
12 |
15 |
array<char, 50>->unsigned char |
!!! <1 !!! |
100 |
11 |
10 |
array<char, 50>->int |
!!! 6 !!! |
114 |
27 |
22 |
array<char, 50>->short |
!!! 5 !!! |
113 |
23 |
23 |
array<char, 50>->long int |
!!! 7 !!! |
118 |
22 |
23 |
array<char, 50>->long long |
!!! 7 !!! |
114 |
26 |
23 |
array<char, 50>->unsigned int |
!!! 6 !!! |
113 |
27 |
23 |
array<char, 50>->unsigned short |
!!! 5 !!! |
124 |
21 |
23 |
array<char, 50>->unsigned long int |
!!! 7 !!! |
116 |
23 |
21 |
array<char, 50>->unsigned long long |
!!! 7 !!! |
115 |
22 |
21 |
array<char, 50>->float |
!!! 11 !!! |
162 |
58 |
36 |
array<char, 50>->double |
!!! 13 !!! |
155 |
54 |
44 |
array<char, 50>->long double |
111 |
149 |
55 |
!!! 42 !!! |
array<char, 50>->array<char, 50> |
!!! 1 !!! |
114 |
18 |
14 |
array<char, 50>->string |
!!! 7 !!! |
129 |
29 |
--- |
array<char, 50>->container::string |
!!! 3 !!! |
113 |
26 |
--- |
int->int |
!!! <1 !!! |
114 |
25 |
--- |
float->double |
!!! <1 !!! |
236 |
121 |
--- |
char->signed char |
!!! <1 !!! |
97 |
8 |
--- |