36
36
#include < memory>
37
37
#include < numeric>
38
38
#include < cstdio>
39
+ #include < sstream>
39
40
#include < vector>
40
41
41
42
#include " test_suite.hpp"
@@ -57,6 +58,8 @@ std::stringstream strout;
57
58
parse_options popts;
58
59
bool with_file_io = false ;
59
60
61
+ char const * external_command = nullptr ;
62
+
60
63
#if defined(__clang__)
61
64
string_view toolset = " clang" ;
62
65
#elif defined(__GNUC__)
@@ -173,6 +176,40 @@ print_prefix(
173
176
arch << " ," << impl.name ();
174
177
}
175
178
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
+
176
213
void
177
214
bench (
178
215
string_view verb,
@@ -203,7 +240,10 @@ bench(
203
240
repeat = 1000 ;
204
241
for (unsigned k = 0 ; k < Trials; ++k)
205
242
{
243
+ start_external (vf[i], *vi[j], verb);
206
244
auto result = run_for (std::chrono::seconds (5 ), f);
245
+ finish_external (vf[i], *vi[j], verb, result);
246
+
207
247
result.calls *= repeat;
208
248
result.mbs = megabytes_per_second (
209
249
vf[i], result.calls , result.millis );
@@ -1159,6 +1199,8 @@ main(
1159
1199
return 4 ;
1160
1200
}
1161
1201
1202
+ external_command = std::getenv (" BOOST_JSON_BENCH_EXTERNAL_COMMAND" );
1203
+
1162
1204
file_list vf;
1163
1205
1164
1206
for ( int i = 1 ; i < argc; ++i )
0 commit comments