results.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. // Copyright (c) 2001 Samuel Krempp
  2. // krempp@crans.ens-cachan.fr
  3. // Distributed under the Boost Software License, Version 1.0. (See accompany-
  4. // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // This benchmark is provided purely for information.
  6. // It might not even compile as-is,
  7. // or not give any sensible results.
  8. // (e.g., it expects sprintf to be POSIX compliant)
  9. new results ( with outsstream vs. stringstream)
  10. bjam -sTOOLS="gcc intel-linux-7.1" -sBUILD="release"
  11. ( -sBUILD="profile" for profiling..)
  12. "_no_reuse_stream" "_stringstr" "_strstream" _no_locale
  13. intel-linux-7.1
  14. for comp in gcc ; do
  15. echo "\n------------------- Compiler $comp : ---------------- "
  16. for var in _overloads _basicfmt _normal; do
  17. echo "\n-- Variant **" $var "**" :
  18. texe=$EXEBOOST/libs/format/benchmark/bench_format${var}/${comp}/release/bench_format${var} ;
  19. ls -l $texe;
  20. $texe
  21. done
  22. done
  23. // stringstream recréé chaque fois.
  24. -- Variant ** _normal ** :
  25. -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
  26. printf time :2.16
  27. ostream time : 3.69, = 1.70833 * printf
  28. parsed-once time : 8.45, = 3.91204 * printf , = 2.28997 * nullStream
  29. reused format time :10.94, = 5.06481 * printf , = 2.96477 * nullStream
  30. format time :10.97, = 5.0787 * printf , = 2.9729 * nullStream
  31. Pour le parsing. step 1 : scan_not + str2int (version Iter const& qques % mieux)
  32. ------------------- Compiler gcc : ----------------
  33. -- Variant ** _overloads ** :
  34. -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
  35. printf time :2.21
  36. ostream time : 3.57, = 1.61538 * printf
  37. parsed-once time : 4.93, = 2.23077 * printf , = 1.38095 * nullStream
  38. reused format time : 9.25, = 4.18552 * printf , = 2.59104 * nullStream
  39. format time :10.33, = 4.67421 * printf , = 2.89356 * nullStream
  40. -- Variant ** _basicfmt ** :
  41. -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
  42. printf time :2.2
  43. ostream time : 3.57, = 1.62273 * printf
  44. parsed-once time : 4.85, = 2.20455 * printf , = 1.35854 * nullStream
  45. reused format time : 9.25, = 4.20455 * printf , = 2.59104 * nullStream
  46. format time :10.29, = 4.67727 * printf , = 2.88235 * nullStream
  47. -- Variant ** _normal ** :
  48. -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
  49. printf time :2.27
  50. ostream time : 3.47, = 1.52863 * printf
  51. parsed-once time : 4.79, = 2.11013 * printf , = 1.3804 * nullStream
  52. reused format time : 9.88, = 4.35242 * printf , = 2.84726 * nullStream
  53. format time :10.97, = 4.8326 * printf , = 3.16138 * nullStream
  54. -------------------------------------------------------------------------------------------------
  55. Overload : int, double char * -> put_simple :
  56. #if defined(BOOST_FORMAT_OVERLOADS)
  57. template<class T>
  58. basic_format& operator%(const char* x)
  59. { return io::detail::feed_overloaded(*this,x); }
  60. template<class T>
  61. basic_format& operator%(const double x)
  62. { return io::detail::feed_overloaded(*this,x); }
  63. template<class T>
  64. basic_format& operator%(const int x)
  65. { return io::detail::feed_overloaded(*this,x); }
  66. #endif
  67. // put overloads for common types (-> faster)
  68. template< class Ch, class Tr, class T>
  69. void put_simple( T x,
  70. const format_item<Ch, Tr>& specs,
  71. std::basic_string<Ch, Tr> & res,
  72. io::basic_outsstream<Ch, Tr>& oss_ )
  73. {
  74. typedef std::basic_string<Ch, Tr> string_t;
  75. typedef format_item<Ch, Tr> format_item_t;
  76. specs.fmtstate_.apply_on(oss_);
  77. const std::ios_base::fmtflags fl=oss_.flags();
  78. const std::streamsize w = oss_.width();
  79. if(w!=0)
  80. oss_.width(0);
  81. put_last( oss_, x);
  82. const Ch * res_beg = oss_.begin();
  83. std::streamsize res_size = std::min(specs.truncate_, oss_.pcount());
  84. int prefix_space = 0;
  85. if(specs.pad_scheme_ & format_item_t::spacepad)
  86. if( res_size == 0 || ( res_beg[0] !='+' && res_beg[0] !='-' ))
  87. prefix_space = 1;
  88. mk_str(res, res_beg, res_size, w, oss_.fill(), fl,
  89. prefix_space, (specs.pad_scheme_ & format_item_t::centered) !=0 );
  90. clear_buffer( oss_);
  91. } // end- put_simple(..)
  92. ------------------- Compiler gcc : ----------------
  93. -- Variant ** _overloads ** :
  94. -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
  95. printf time :2.13
  96. ostream time : 2.91, = 1.3662 * printf
  97. parsed-once time : 4.48, = 2.10329 * printf , = 1.53952 * nullStream
  98. reused format time : 9.42, = 4.42254 * printf , = 3.23711 * nullStream
  99. format time : 11.1, = 5.21127 * printf , = 3.81443 * nullStream
  100. RERUN
  101. printf time :2.09
  102. ostream time : 2.92, = 1.39713 * printf
  103. parsed-once time : 4.43, = 2.11962 * printf , = 1.51712 * nullStream
  104. reused format time : 9.29, = 4.44498 * printf , = 3.18151 * nullStream
  105. format time :11.05, = 5.28708 * printf , = 3.78425 * nullStream
  106. -- Variant ** _basicfmt ** :
  107. -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
  108. printf time :2.16
  109. ostream time : 3.01, = 1.39352 * printf
  110. parsed-once time : 4.41, = 2.04167 * printf , = 1.46512 * nullStream
  111. reused format time : 9.61, = 4.44907 * printf , = 3.19269 * nullStream
  112. format time :11.02, = 5.10185 * printf , = 3.66113 * nullStream
  113. -- Variant ** _no_locale ** :
  114. -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
  115. printf time :2.1
  116. ostream time : 2.87, = 1.36667 * printf
  117. parsed-once time : 4.44, = 2.11429 * printf , = 1.54704 * nullStream
  118. reused format time : 8.21, = 3.90952 * printf , = 2.86063 * nullStream
  119. format time : 9.25, = 4.40476 * printf , = 3.223 * nullStream
  120. -- Variant ** _normal ** :
  121. -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
  122. printf time :2.18
  123. ostream time : 2.92, = 1.33945 * printf
  124. parsed-once time : 5.75, = 2.63761 * printf , = 1.96918 * nullStream
  125. reused format time :10.27, = 4.71101 * printf , = 3.51712 * nullStream
  126. ------------------- Compiler gcc : ----------------
  127. -- Variant ** _normal ** :
  128. -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
  129. printf time :2.16
  130. ostream time : 2.81, = 1.30093 * printf
  131. stored format time :11.56, = 5.35185 * printf , = 4.11388 * nullStream
  132. format time :18.69, = 8.65278 * printf , = 6.65125 * nullStream
  133. -- Variant ** _static_stream ** :
  134. -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
  135. printf time :2.1
  136. ostream time : 2.79, = 1.32857 * printf
  137. stored format time : 4.5, = 2.14286 * printf , = 1.6129 * nullStream
  138. format time :10.05, = 4.78571 * printf , = 3.60215 * nullStream
  139. -- Variant ** _basicfmt ** :
  140. -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
  141. printf time :2.22
  142. ostream time : 2.88, = 1.2973 * printf
  143. stored format time : 4.45, = 2.0045 * printf , = 1.54514 * nullStream
  144. format time :11.67, = 5.25676 * printf , = 4.05208 * nullStream
  145. The cost of imbuing locale after each object is fed :
  146. ------------------- Compiler gcc : ----------------
  147. -- Variant _normal :
  148. -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
  149. printf time :2.21
  150. ostream time : 3.1, = 1.40271 * printf
  151. stored format time :11.53, = 3.71935 * stream
  152. format time :18.86, = 6.08387 * stream
  153. -- Variant _static_stream :
  154. -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
  155. printf time :2.19
  156. ostream time : 3.09, = 1.41096 * printf
  157. stored format time : 4.63, = 1.49838 * stream
  158. format time :10.12, = 3.27508 * stream
  159. -- Variant _basicfmt :
  160. -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
  161. printf time :2.23
  162. ostream time : 3.14, = 1.40807 * printf
  163. stored format time : 4.61, = 1.46815 * stream
  164. format time :11.33, = 3.60828 * stream
  165. ------------------- Compiler gcc : ----------------
  166. -- Variant _normal :
  167. printf time :2.15
  168. ostream time :4.42, = 2.05581 * printf
  169. stored format time :5.85, = 1.32353 * stream
  170. format time :11.53, = 2.6086 * stream
  171. -- Variant _no_reuse_stream :
  172. printf time :2.13
  173. ostream time :4.4, = 2.06573 * printf
  174. stored format time :11.1, = 2.52273 * stream
  175. format time :14.3, = 3.25 * stream
  176. -- Variant _stringstr :
  177. printf time :2.01
  178. ostream time :4.42, = 2.199 * printf
  179. stored format time :7.92, = 1.79186 * stream
  180. format time :12.8, = 2.89593 * stream
  181. ------------------- Compiler intel-linux-7.1 : ----------------
  182. -- Variant _normal :
  183. printf time :2.08
  184. ostream time :4.49, = 2.15865 * printf
  185. stored format time :5.3, = 1.1804 * stream
  186. format time :17.8, = 3.96437 * stream
  187. -- Variant _no_reuse_stream :
  188. printf time :2.09
  189. ostream time :4.37, = 2.09091 * printf
  190. stored format time :10.07, = 2.30435 * stream
  191. format time :14.46, = 3.30892 * stream
  192. -- Variant _stringstr :
  193. printf time :1.99
  194. ostream time :5.16, = 2.59296 * printf
  195. stored format time :5.83, = 1.12984 * stream
  196. format time :17.42, = 3.37597 * stream
  197. // older Result with gcc-3.03 on linux :
  198. // With flag -g :
  199. /***
  200. printf time :1.2
  201. ostream time :2.84, = 2.36667 * printf
  202. stored format time :8.91, = 3.13732 * stream
  203. format time :15.35, = 5.40493 * stream
  204. format3 time :21.83, = 7.68662 * stream
  205. ***/
  206. // With flag -O
  207. /***
  208. printf time :1.16
  209. ostream time :1.94, = 1.67241 * printf
  210. stored format time :3.68, = 1.89691 * stream
  211. format time :6.31, = 3.25258 * stream
  212. format3 time :9.04, = 4.65979 * stream
  213. ***/
  214. // ==> that's quite acceptable.
  215. // ------------------------------------------------------------------------------