1
// This benchmark is provided purely for information.
2
// It might not even compile as-is,
3
// or not give any sensible results.
4
// (e.g., it expects sprintf to be POSIX compliant)
6
new results ( with outsstream vs. stringstream)
8
bjam -sTOOLS="gcc intel-linux-7.1" -sBUILD="release"
10
( -sBUILD="profile" for profiling..)
13
"_no_reuse_stream" "_stringstr" "_strstream" _no_locale
18
echo "\n------------------- Compiler $comp : ---------------- "
19
for var in _overloads _basicfmt _normal; do
20
echo "\n-- Variant **" $var "**" :
21
texe=$EXEBOOST/libs/format/benchmark/bench_format${var}/${comp}/release/bench_format${var} ;
28
// stringstream recr�� chaque fois.
29
-- Variant ** _normal ** :
30
-rwx--x--x 1 sam users 61952 Sep 17 03:13 /home/data/zStore/BBoost/bin/boost//libs/format/benchmark/bench_format_normal/gcc/release/bench_format_normal
32
ostream time : 3.69, = 1.70833 * printf
33
parsed-once time : 8.45, = 3.91204 * printf , = 2.28997 * nullStream
34
reused format time :10.94, = 5.06481 * printf , = 2.96477 * nullStream
35
format time :10.97, = 5.0787 * printf , = 2.9729 * nullStream
38
Pour le parsing. step 1 : scan_not + str2int (version Iter const& qques % mieux)
40
------------------- Compiler gcc : ----------------
42
-- Variant ** _overloads ** :
43
-rwx--x--x 1 sam users 52864 2003-09-12 02:59 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_overloads/gcc/release/bench_format_overloads
45
ostream time : 3.57, = 1.61538 * printf
46
parsed-once time : 4.93, = 2.23077 * printf , = 1.38095 * nullStream
47
reused format time : 9.25, = 4.18552 * printf , = 2.59104 * nullStream
48
format time :10.33, = 4.67421 * printf , = 2.89356 * nullStream
50
-- Variant ** _basicfmt ** :
51
-rwx--x--x 1 sam users 52864 2003-09-12 03:00 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_basicfmt/gcc/release/bench_format_basicfmt
53
ostream time : 3.57, = 1.62273 * printf
54
parsed-once time : 4.85, = 2.20455 * printf , = 1.35854 * nullStream
55
reused format time : 9.25, = 4.20455 * printf , = 2.59104 * nullStream
56
format time :10.29, = 4.67727 * printf , = 2.88235 * nullStream
58
-- Variant ** _normal ** :
59
-rwx--x--x 1 sam users 53088 2003-09-12 03:00 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_normal/gcc/release/bench_format_normal
61
ostream time : 3.47, = 1.52863 * printf
62
parsed-once time : 4.79, = 2.11013 * printf , = 1.3804 * nullStream
63
reused format time : 9.88, = 4.35242 * printf , = 2.84726 * nullStream
64
format time :10.97, = 4.8326 * printf , = 3.16138 * nullStream
66
-------------------------------------------------------------------------------------------------
67
Overload : int, double char * -> put_simple :
68
#if defined(BOOST_FORMAT_OVERLOADS)
70
basic_format& operator%(const char* x)
71
{ return io::detail::feed_overloaded(*this,x); }
73
basic_format& operator%(const double x)
74
{ return io::detail::feed_overloaded(*this,x); }
76
basic_format& operator%(const int x)
77
{ return io::detail::feed_overloaded(*this,x); }
80
// put overloads for common types (-> faster)
81
template< class Ch, class Tr, class T>
83
const format_item<Ch, Tr>& specs,
84
std::basic_string<Ch, Tr> & res,
85
io::basic_outsstream<Ch, Tr>& oss_ )
87
typedef std::basic_string<Ch, Tr> string_t;
88
typedef format_item<Ch, Tr> format_item_t;
90
specs.fmtstate_.apply_on(oss_);
91
const std::ios_base::fmtflags fl=oss_.flags();
92
const std::streamsize w = oss_.width();
97
const Ch * res_beg = oss_.begin();
98
std::streamsize res_size = std::min(specs.truncate_, oss_.pcount());
100
if(specs.pad_scheme_ & format_item_t::spacepad)
101
if( res_size == 0 || ( res_beg[0] !='+' && res_beg[0] !='-' ))
103
mk_str(res, res_beg, res_size, w, oss_.fill(), fl,
104
prefix_space, (specs.pad_scheme_ & format_item_t::centered) !=0 );
106
} // end- put_simple(..)
110
------------------- Compiler gcc : ----------------
112
-- Variant ** _overloads ** :
113
-rwx--x--x 1 sam users 52832 2003-09-12 00:17 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_overloads/gcc/release/bench_format_overloads
115
ostream time : 2.91, = 1.3662 * printf
116
parsed-once time : 4.48, = 2.10329 * printf , = 1.53952 * nullStream
117
reused format time : 9.42, = 4.42254 * printf , = 3.23711 * nullStream
118
format time : 11.1, = 5.21127 * printf , = 3.81443 * nullStream
122
ostream time : 2.92, = 1.39713 * printf
123
parsed-once time : 4.43, = 2.11962 * printf , = 1.51712 * nullStream
124
reused format time : 9.29, = 4.44498 * printf , = 3.18151 * nullStream
125
format time :11.05, = 5.28708 * printf , = 3.78425 * nullStream
127
-- Variant ** _basicfmt ** :
128
-rwx--x--x 1 sam users 52832 2003-09-12 00:17 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_basicfmt/gcc/release/bench_format_basicfmt
130
ostream time : 3.01, = 1.39352 * printf
131
parsed-once time : 4.41, = 2.04167 * printf , = 1.46512 * nullStream
132
reused format time : 9.61, = 4.44907 * printf , = 3.19269 * nullStream
133
format time :11.02, = 5.10185 * printf , = 3.66113 * nullStream
135
-- Variant ** _no_locale ** :
136
-rwx--x--x 1 sam users 52192 2003-09-12 00:09 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_no_locale/gcc/release/bench_format_no_locale
138
ostream time : 2.87, = 1.36667 * printf
139
parsed-once time : 4.44, = 2.11429 * printf , = 1.54704 * nullStream
140
reused format time : 8.21, = 3.90952 * printf , = 2.86063 * nullStream
141
format time : 9.25, = 4.40476 * printf , = 3.223 * nullStream
143
-- Variant ** _normal ** :
144
-rwx--x--x 1 sam users 53056 2003-09-12 00:17 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_normal/gcc/release/bench_format_normal
146
ostream time : 2.92, = 1.33945 * printf
147
parsed-once time : 5.75, = 2.63761 * printf , = 1.96918 * nullStream
148
reused format time :10.27, = 4.71101 * printf , = 3.51712 * nullStream
169
------------------- Compiler gcc : ----------------
171
-- Variant ** _normal ** :
172
-rwx--x--x 1 sam users 49280 2003-09-10 21:12 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_normal/gcc/release/bench_format_normal
174
ostream time : 2.81, = 1.30093 * printf
175
stored format time :11.56, = 5.35185 * printf , = 4.11388 * nullStream
176
format time :18.69, = 8.65278 * printf , = 6.65125 * nullStream
178
-- Variant ** _static_stream ** :
179
-rwx--x--x 1 sam users 45856 2003-09-10 21:13 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_static_stream/gcc/release/bench_format_static_stream
181
ostream time : 2.79, = 1.32857 * printf
182
stored format time : 4.5, = 2.14286 * printf , = 1.6129 * nullStream
183
format time :10.05, = 4.78571 * printf , = 3.60215 * nullStream
185
-- Variant ** _basicfmt ** :
186
-rwx--x--x 1 sam users 47200 2003-09-10 21:13 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_basicfmt/gcc/release/bench_format_basicfmt
188
ostream time : 2.88, = 1.2973 * printf
189
stored format time : 4.45, = 2.0045 * printf , = 1.54514 * nullStream
190
format time :11.67, = 5.25676 * printf , = 4.05208 * nullStream
196
The cost of imbuing locale after each object is fed :
198
------------------- Compiler gcc : ----------------
200
-rwx--x--x 1 sam users 49920 2003-09-10 20:23 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_normal/gcc/release/bench_format_normal
202
ostream time : 3.1, = 1.40271 * printf
203
stored format time :11.53, = 3.71935 * stream
204
format time :18.86, = 6.08387 * stream
206
-- Variant _static_stream :
207
-rwx--x--x 1 sam users 43232 2003-09-10 20:24 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_static_stream/gcc/release/bench_format_static_stream
209
ostream time : 3.09, = 1.41096 * printf
210
stored format time : 4.63, = 1.49838 * stream
211
format time :10.12, = 3.27508 * stream
213
-- Variant _basicfmt :
214
-rwx--x--x 1 sam users 45760 2003-09-10 20:24 /home/sam/progs/Boost/bin/BBoost//libs/format/benchmark/bench_format_basicfmt/gcc/release/bench_format_basicfmt
216
ostream time : 3.14, = 1.40807 * printf
217
stored format time : 4.61, = 1.46815 * stream
218
format time :11.33, = 3.60828 * stream
226
------------------- Compiler gcc : ----------------
229
ostream time :4.42, = 2.05581 * printf
230
stored format time :5.85, = 1.32353 * stream
231
format time :11.53, = 2.6086 * stream
232
-- Variant _no_reuse_stream :
234
ostream time :4.4, = 2.06573 * printf
235
stored format time :11.1, = 2.52273 * stream
236
format time :14.3, = 3.25 * stream
237
-- Variant _stringstr :
239
ostream time :4.42, = 2.199 * printf
240
stored format time :7.92, = 1.79186 * stream
241
format time :12.8, = 2.89593 * stream
243
------------------- Compiler intel-linux-7.1 : ----------------
246
ostream time :4.49, = 2.15865 * printf
247
stored format time :5.3, = 1.1804 * stream
248
format time :17.8, = 3.96437 * stream
249
-- Variant _no_reuse_stream :
251
ostream time :4.37, = 2.09091 * printf
252
stored format time :10.07, = 2.30435 * stream
253
format time :14.46, = 3.30892 * stream
254
-- Variant _stringstr :
256
ostream time :5.16, = 2.59296 * printf
257
stored format time :5.83, = 1.12984 * stream
258
format time :17.42, = 3.37597 * stream
263
// older Result with gcc-3.03 on linux :
269
ostream time :2.84, = 2.36667 * printf
270
stored format time :8.91, = 3.13732 * stream
271
format time :15.35, = 5.40493 * stream
272
format3 time :21.83, = 7.68662 * stream
280
ostream time :1.94, = 1.67241 * printf
281
stored format time :3.68, = 1.89691 * stream
282
format time :6.31, = 3.25258 * stream
283
format3 time :9.04, = 4.65979 * stream
286
// ==> that's quite acceptable.
288
// ------------------------------------------------------------------------------