3636#include < memory>
3737#include < numeric>
3838#include < cstdio>
39+ #include < sstream>
3940#include < vector>
4041
4142#include " test_suite.hpp"
@@ -57,6 +58,8 @@ std::stringstream strout;
5758parse_options popts;
5859bool with_file_io = false ;
5960
61+ char const * external_command = nullptr ;
62+
6063#if defined(__clang__)
6164string_view toolset = " clang" ;
6265#elif defined(__GNUC__)
@@ -173,6 +176,40 @@ print_prefix(
173176 arch << " ," << impl.name ();
174177}
175178
179+ void
180+ start_external (file_item const & f, any_impl const & i, string_view verb)
181+ {
182+ if ( !external_command )
183+ return ;
184+
185+ std::stringstream command;
186+ command << external_command << " Starting \" " ;
187+ print_prefix (command, f, i, verb ) << ' "' ;
188+ std::string const command_s = command.str ();
189+ (void )std::system ( command_s.c_str () );
190+ }
191+
192+ void
193+ finish_external (
194+ file_item const & f,
195+ any_impl const & i,
196+ string_view verb,
197+ sample const & result)
198+ {
199+ if ( !external_command )
200+ return ;
201+
202+ std::stringstream command;
203+ command << external_command << " Completed \" " ;
204+ print_prefix (command, f, i, verb )
205+ << " ," << result.calls
206+ << " ," << result.millis
207+ << " ," << result.mbs
208+ << ' "' ;
209+ std::string const command_s = command.str ();
210+ (void )std::system ( command_s.c_str () );
211+ }
212+
176213void
177214bench (
178215 string_view verb,
@@ -203,7 +240,10 @@ bench(
203240 repeat = 1000 ;
204241 for (unsigned k = 0 ; k < Trials; ++k)
205242 {
243+ start_external (vf[i], *vi[j], verb);
206244 auto result = run_for (std::chrono::seconds (5 ), f);
245+ finish_external (vf[i], *vi[j], verb, result);
246+
207247 result.calls *= repeat;
208248 result.mbs = megabytes_per_second (
209249 vf[i], result.calls , result.millis );
@@ -1159,6 +1199,8 @@ main(
11591199 return 4 ;
11601200 }
11611201
1202+ external_command = std::getenv (" BOOST_JSON_BENCH_EXTERNAL_COMMAND" );
1203+
11621204 file_list vf;
11631205
11641206 for ( int i = 1 ; i < argc; ++i )
0 commit comments