@@ -57,6 +57,8 @@ std::stringstream strout;
5757parse_options popts;
5858bool with_file_io = false ;
5959
60+ char const * external_command = nullptr ;
61+
6062#if defined(__clang__)
6163string_view toolset = " clang" ;
6264#elif defined(__GNUC__)
@@ -173,6 +175,22 @@ print_prefix(
173175 arch << " ," << impl.name ();
174176}
175177
178+ void
179+ run_external (char const * op, file_item const & f)
180+ {
181+ if ( !external_command )
182+ return ;
183+
184+ std::string command = external_command;
185+ command += ' ' ;
186+ command += op;
187+ command += ' ' ;
188+ command += toolset;
189+ command += ' ' ;
190+ command += f.name ;
191+ (void )std::system ( command.c_str () );
192+ }
193+
176194void
177195bench (
178196 string_view verb,
@@ -203,7 +221,10 @@ bench(
203221 repeat = 1000 ;
204222 for (unsigned k = 0 ; k < Trials; ++k)
205223 {
224+ run_external (" start" , vf[i]);
206225 auto result = run_for (std::chrono::seconds (5 ), f);
226+ run_external (" finish" , vf[i]);
227+
207228 result.calls *= repeat;
208229 result.mbs = megabytes_per_second (
209230 vf[i], result.calls , result.millis );
@@ -1159,6 +1180,8 @@ main(
11591180 return 4 ;
11601181 }
11611182
1183+ external_command = std::getenv (" BOOST_JSON_BENCH_EXTERNAL_COMMAND" );
1184+
11621185 file_list vf;
11631186
11641187 for ( int i = 1 ; i < argc; ++i )
0 commit comments