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) |
---|
5 | |
---|
6 | new results ( with outsstream vs. stringstream) |
---|
7 | |
---|
8 | bjam -sTOOLS="gcc intel-linux-7.1" -sBUILD="release" |
---|
9 | |
---|
10 | ( -sBUILD="profile" for profiling..) |
---|
11 | |
---|
12 | |
---|
13 | "_no_reuse_stream" "_stringstr" "_strstream" _no_locale |
---|
14 | |
---|
15 | intel-linux-7.1 |
---|
16 | |
---|
17 | for comp in gcc ; do |
---|
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} ; |
---|
22 | ls -l $texe; |
---|
23 | $texe |
---|
24 | done |
---|
25 | done |
---|
26 | |
---|
27 | |
---|
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 |
---|
31 | printf time :2.16 |
---|
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 |
---|
36 | |
---|
37 | |
---|
38 | Pour le parsing. step 1 : scan_not + str2int (version Iter const& qques % mieux) |
---|
39 | |
---|
40 | ------------------- Compiler gcc : ---------------- |
---|
41 | |
---|
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 |
---|
44 | printf time :2.21 |
---|
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 |
---|
49 | |
---|
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 |
---|
52 | printf time :2.2 |
---|
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 |
---|
57 | |
---|
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 |
---|
60 | printf time :2.27 |
---|
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 |
---|
65 | |
---|
66 | ------------------------------------------------------------------------------------------------- |
---|
67 | Overload : int, double char * -> put_simple : |
---|
68 | #if defined(BOOST_FORMAT_OVERLOADS) |
---|
69 | template<class T> |
---|
70 | basic_format& operator%(const char* x) |
---|
71 | { return io::detail::feed_overloaded(*this,x); } |
---|
72 | template<class T> |
---|
73 | basic_format& operator%(const double x) |
---|
74 | { return io::detail::feed_overloaded(*this,x); } |
---|
75 | template<class T> |
---|
76 | basic_format& operator%(const int x) |
---|
77 | { return io::detail::feed_overloaded(*this,x); } |
---|
78 | #endif |
---|
79 | |
---|
80 | // put overloads for common types (-> faster) |
---|
81 | template< class Ch, class Tr, class T> |
---|
82 | void put_simple( T x, |
---|
83 | const format_item<Ch, Tr>& specs, |
---|
84 | std::basic_string<Ch, Tr> & res, |
---|
85 | io::basic_outsstream<Ch, Tr>& oss_ ) |
---|
86 | { |
---|
87 | typedef std::basic_string<Ch, Tr> string_t; |
---|
88 | typedef format_item<Ch, Tr> format_item_t; |
---|
89 | |
---|
90 | specs.fmtstate_.apply_on(oss_); |
---|
91 | const std::ios_base::fmtflags fl=oss_.flags(); |
---|
92 | const std::streamsize w = oss_.width(); |
---|
93 | |
---|
94 | if(w!=0) |
---|
95 | oss_.width(0); |
---|
96 | put_last( oss_, x); |
---|
97 | const Ch * res_beg = oss_.begin(); |
---|
98 | std::streamsize res_size = std::min(specs.truncate_, oss_.pcount()); |
---|
99 | int prefix_space = 0; |
---|
100 | if(specs.pad_scheme_ & format_item_t::spacepad) |
---|
101 | if( res_size == 0 || ( res_beg[0] !='+' && res_beg[0] !='-' )) |
---|
102 | prefix_space = 1; |
---|
103 | mk_str(res, res_beg, res_size, w, oss_.fill(), fl, |
---|
104 | prefix_space, (specs.pad_scheme_ & format_item_t::centered) !=0 ); |
---|
105 | clear_buffer( oss_); |
---|
106 | } // end- put_simple(..) |
---|
107 | |
---|
108 | |
---|
109 | |
---|
110 | ------------------- Compiler gcc : ---------------- |
---|
111 | |
---|
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 |
---|
114 | printf time :2.13 |
---|
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 |
---|
119 | |
---|
120 | RERUN |
---|
121 | printf time :2.09 |
---|
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 |
---|
126 | |
---|
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 |
---|
129 | printf time :2.16 |
---|
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 |
---|
134 | |
---|
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 |
---|
137 | printf time :2.1 |
---|
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 |
---|
142 | |
---|
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 |
---|
145 | printf time :2.18 |
---|
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 |
---|
149 | |
---|
150 | |
---|
151 | |
---|
152 | |
---|
153 | |
---|
154 | |
---|
155 | |
---|
156 | |
---|
157 | |
---|
158 | |
---|
159 | |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | |
---|
164 | |
---|
165 | |
---|
166 | |
---|
167 | |
---|
168 | |
---|
169 | ------------------- Compiler gcc : ---------------- |
---|
170 | |
---|
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 |
---|
173 | printf time :2.16 |
---|
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 |
---|
177 | |
---|
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 |
---|
180 | printf time :2.1 |
---|
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 |
---|
184 | |
---|
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 |
---|
187 | printf time :2.22 |
---|
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 |
---|
191 | |
---|
192 | |
---|
193 | |
---|
194 | |
---|
195 | |
---|
196 | The cost of imbuing locale after each object is fed : |
---|
197 | |
---|
198 | ------------------- Compiler gcc : ---------------- |
---|
199 | -- Variant _normal : |
---|
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 |
---|
201 | printf time :2.21 |
---|
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 |
---|
205 | |
---|
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 |
---|
208 | printf time :2.19 |
---|
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 |
---|
212 | |
---|
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 |
---|
215 | printf time :2.23 |
---|
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 |
---|
219 | |
---|
220 | |
---|
221 | |
---|
222 | |
---|
223 | |
---|
224 | |
---|
225 | |
---|
226 | ------------------- Compiler gcc : ---------------- |
---|
227 | -- Variant _normal : |
---|
228 | printf time :2.15 |
---|
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 : |
---|
233 | printf time :2.13 |
---|
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 : |
---|
238 | printf time :2.01 |
---|
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 |
---|
242 | |
---|
243 | ------------------- Compiler intel-linux-7.1 : ---------------- |
---|
244 | -- Variant _normal : |
---|
245 | printf time :2.08 |
---|
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 : |
---|
250 | printf time :2.09 |
---|
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 : |
---|
255 | printf time :1.99 |
---|
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 |
---|
259 | |
---|
260 | |
---|
261 | |
---|
262 | |
---|
263 | // older Result with gcc-3.03 on linux : |
---|
264 | |
---|
265 | // With flag -g : |
---|
266 | |
---|
267 | /*** |
---|
268 | printf time :1.2 |
---|
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 |
---|
273 | ***/ |
---|
274 | |
---|
275 | |
---|
276 | // With flag -O |
---|
277 | |
---|
278 | /*** |
---|
279 | printf time :1.16 |
---|
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 |
---|
284 | ***/ |
---|
285 | |
---|
286 | // ==> that's quite acceptable. |
---|
287 | |
---|
288 | // ------------------------------------------------------------------------------ |
---|