MCPcopy Create free account
hub / github.com/boostorg/json / do_test

Function do_test

bench/bench-conv.cpp:350–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348}
349
350bool
351do_test(file_list const & vf, impl_list const & vi, char test)
352{
353 string_view verb;
354 switch(test)
355 {
356 case 'p':
357 verb = "Parse";
358 break;
359 case 's':
360 verb = "Serialize";
361 break;
362 default:
363 std::cerr << "Unknown test type: '" << test << "'\n";
364 return false;
365 }
366
367 std::vector<sample> trial;
368 for(unsigned i = 0; i < vf.size(); ++i)
369 {
370 for(unsigned j = 0; j < vi.size(); ++j)
371 {
372 trial.clear();
373 std::size_t repeat = 1;
374
375 auto const f = [&]{
376 return vi[j].get()->bench(verb, vf[i], repeat);
377 };
378
379 // helps with the caching, which reduces noise; also, we determine
380 // if this configuration should be skipped altogether
381 auto const elapsed = f();
382 if( elapsed == std::chrono::milliseconds::zero() )
383 {
384 print_prefix(dout, vf[i], *vi[j], verb)
385 << "," << "N/A"
386 << "," << "N/A"
387 << "," << "N/A"
388 << "\n";
389 print_prefix(strout, vf[i], *vi[j], verb)
390 << "," << "N/A" << "\n";
391 continue;
392 }
393
394 repeat = 1000;
395 for(unsigned k = 0; k < s_trials; ++k)
396 {
397 auto result = run_for(std::chrono::seconds(5), f);
398 result.calls *= repeat;
399 result.mbs = megabytes_per_second(
400 vf[i], result.calls, result.millis);
401 print_prefix(dout, vf[i], *vi[j], verb)
402 << "," << result.calls
403 << "," << result.millis
404 << "," << result.mbs
405 << "\n";
406 trial.push_back(result);
407 // adjust repeat to avoid overlong tests

Callers 1

mainFunction · 0.70

Calls 11

resizeMethod · 0.80
run_forFunction · 0.70
megabytes_per_secondFunction · 0.70
fFunction · 0.50
sizeMethod · 0.45
clearMethod · 0.45
benchMethod · 0.45
getMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected