77#include < sstream>
88#include < string>
99#include < charconv>
10+ #include < iomanip>
1011
1112using namespace simstr ;
1213using namespace std ::literals;
@@ -183,17 +184,25 @@ BENCHMARK(ConcatSimToSimHexC) ->Name("Concat stringa and hex number and litera
183184BENCHMARK (ConcatSimToSimHexS) ->Name(" Subst stringa and hex number by e_subst literal to simstr::stringa" );
184185BENCHMARK (ConcatSimToSimHexVS) ->Name(" Subst stringa and hex number by e_vsubst stra to simstr::stringa" );
185186
186- void SubstSimToSimBin (benchmark::State& state) {
187- static bool first = true ;
187+ void ConcatSimToSimOct (benchmark::State& state) {
188188 for (auto _: state) {
189189 for (unsigned i = 1 ; i <= 100'000 ; i *= 10 ) {
190- stringa str = e_subst ( " art {} end " , e_int< 8 , f::w< 10 > | f::p | f::z>(i)) ;
190+ stringa str = " art " _ss + i / 0x8a010_fmt + " end " ;
191191 benchmark::DoNotOptimize (str);
192192 }
193193 }
194194}
195195
196- void FormatStdToStdBin (benchmark::State& state) {
196+ void SubstSimToSimOct (benchmark::State& state) {
197+ for (auto _: state) {
198+ for (unsigned i = 1 ; i <= 100'000 ; i *= 10 ) {
199+ stringa str = e_subst (" art {} end" , i / 0x8a010_fmt);
200+ benchmark::DoNotOptimize (str);
201+ }
202+ }
203+ }
204+
205+ void FormatStdToStdOct (benchmark::State& state) {
197206 for (auto _: state) {
198207 for (unsigned i = 1 ; i <= 100'000 ; i *= 10 ) {
199208 std::string str = std::format (" art {:#010o} end" , i);
@@ -202,31 +211,44 @@ void FormatStdToStdBin(benchmark::State& state) {
202211 }
203212}
204213
205- void VSubstSimToSimBin (benchmark::State& state) {
214+ void VSubstSimToSimOct (benchmark::State& state) {
206215 ssa pattern = " art {} end" ;
207216 for (auto _: state) {
208217 for (unsigned i = 1 ; i <= 100'000 ; i *= 10 ) {
209- stringa str = e_vsubst (pattern, e_int< 8 , f::w< 10 > | f::p | f::z>(i) );
218+ stringa str = e_vsubst (pattern, i / 0x8a010_fmt );
210219 benchmark::DoNotOptimize (str);
211220 }
212221 }
213222}
214223
215- void VFormatStdToStdBin (benchmark::State& state) {
224+ void VFormatStdToStdOct (benchmark::State& state) {
216225 std::string_view pattern = " art {:#010o} end" ;
217- static bool first = true ;
218226 for (auto _: state) {
219227 for (unsigned i = 1 ; i <= 100'000 ; i *= 10 ) {
220228 std::string str = std::vformat (pattern, std::make_format_args (i));
221229 benchmark::DoNotOptimize (str);
222230 }
223231 }
224232}
233+
234+ void StreamStdToStdOct (benchmark::State& state) {
235+ for (auto _: state) {
236+ for (unsigned i = 1 ; i <= 100'000 ; i *= 10 ) {
237+ std::stringstream strm;
238+ strm << " art 0" << std::oct << std::setw (9 ) << std::setfill (' 0' ) << i << " end" ;
239+ std::string str = strm.str ();
240+ benchmark::DoNotOptimize (str);
241+ }
242+ }
243+ }
244+
225245BENCHMARK (__)->Name(" ----- format/vformat and subst/vsubst octal number ---------" )->Repetitions(1 );
226- BENCHMARK (SubstSimToSimBin) ->Name(" e_subst(\" art {} end\" , e_int<8, f::w<10> | f::p | f::z>(i))" );
227- BENCHMARK (FormatStdToStdBin) ->Name(" std::format(\" art {:#010o} end\" , i)" );
228- BENCHMARK (VSubstSimToSimBin) ->Name(" e_vsubst(pattern, e_int<8, f::w<10> | f::p | f::z>(i))" );
229- BENCHMARK (VFormatStdToStdBin) ->Name(" std::vformat(pattern, std::make_format_args(i))" );
246+ BENCHMARK (ConcatSimToSimOct) ->Name(" \" art \" _ss + i / 0x8a010_fmt + \" end\" " );
247+ BENCHMARK (SubstSimToSimOct) ->Name(" e_subst(\" art {} end\" , i / 0x8a010_fmt)" );
248+ BENCHMARK (VSubstSimToSimOct) ->Name(" e_vsubst(pattern, i / 0x8a010_fmt)" );
249+ BENCHMARK (FormatStdToStdOct) ->Name(" std::format(\" art {:#010o} end\" , i)" );
250+ BENCHMARK (VFormatStdToStdOct) ->Name(" std::vformat(pattern, std::make_format_args(i))" );
251+ BENCHMARK (StreamStdToStdOct) ->Name(" strm << \" art 0\" << std::oct << std::setw(9) << std::setfill('0') << i << \" end\" " );
230252
231253void ConcatStdToStdS (benchmark::State& state) {
232254 std::string s1 = " start " ;
0 commit comments