269 using namespace asg::msgUserCode;
271 auto eventReader = makeEventReader();
274 std::vector<ToolData> toolDataVec;
275 for (
const auto& testDefinition : testDefinitions)
277 if (testDefinition.xAODToolCaller !=
nullptr)
280 toolData.name = testDefinition.name;
281 toolData.xAODToolCaller = testDefinition.xAODToolCaller;
282 toolData.noRepeatCall = testDefinition.noRepeatCall;
283 toolDataVec.push_back(std::move(toolData));
288 if (!testDefinitions.empty() && testDefinitions[0].tool)
289 evtStore = &*testDefinitions[0].tool->evtStore();
295 throw std::runtime_error (
"ColumnarPhysLiteTest: numberOfEvents == 0");
297 std::uint64_t entry = 0;
304 const auto startTime = std::chrono::high_resolution_clock::now();
305 for (; (std::chrono::high_resolution_clock::now() - startTime) < userConfiguration.
targetTime; ++entry)
310 if (eventReader->hasClearStore())
312 static const std::string prepPostfix =
"Prep";
313 for (
auto& toolData : toolDataVec)
315 for (
auto& toolData : toolDataVec)
317 for (
auto& toolData : toolDataVec)
319 for (
auto& toolData : toolDataVec)
321 eventReader->clearStore();
323 static const std::string callPostfix =
"Call";
324 for (
auto& toolData : toolDataVec)
326 for (
auto& toolData : toolDataVec)
328 for (
auto& toolData : toolDataVec)
336 if (userConfiguration.
runToolTwice && !toolData.noRepeatCall)
341 for (
auto& toolData : toolDataVec)
343 if (eventReader->hasClearStore())
344 eventReader->clearStore();
346 std::cout <<
"Total entries read: " << entry << std::endl;
347 const float emptyTime = benchmarkEmpty.
getEntryTime(0).value();
349 eventReader->printBenchmarkTable(emptyTime);
352 std::vector<std::pair<ToolPerfData, ToolPerfData>> toolPerfData;
353 for (
auto& toolData : toolDataVec)
356 prepPerfData.
name = toolData.name;
357 if (eventReader->hasClearStore()) {
358 prepPerfData.
timeRetrieve = toolData.benchmarkRetrieve[0].getEntryTime(emptyTime);
359 prepPerfData.
timeCopyRecord = toolData.benchmarkCopyRecord[0].getEntryTime(emptyTime);
360 prepPerfData.
timeCall = toolData.benchmarkCall[0].getEntryTime(emptyTime);
361 prepPerfData.
timeClear = toolData.benchmarkClear[0].getEntryTime(emptyTime);
362 toolData.benchmarkRetrieve[0].setSilence();
363 toolData.benchmarkCopyRecord[0].setSilence();
364 toolData.benchmarkCall[0].setSilence();
365 toolData.benchmarkClear[0].setSilence();
369 callPerfData.
name = toolData.name;
370 callPerfData.
timeRetrieve = toolData.benchmarkRetrieve[1].getEntryTime(emptyTime);
371 callPerfData.
timeCopyRecord = toolData.benchmarkCopyRecord[1].getEntryTime(emptyTime);
372 callPerfData.
timeCall = toolData.benchmarkCall[1].getEntryTime(emptyTime);
373 callPerfData.
timeClear = toolData.benchmarkClear[1].getEntryTime(emptyTime);
375 callPerfData.
timeCall2 = toolData.benchmarkCall[2].getEntryTime(emptyTime);
376 toolData.benchmarkCall[2].setSilence();
378 toolData.benchmarkRetrieve[1].setSilence();
379 toolData.benchmarkCopyRecord[1].setSilence();
380 toolData.benchmarkCall[1].setSilence();
381 toolData.benchmarkClear[1].setSilence();
383 toolPerfData.emplace_back(std::move(prepPerfData), std::move(callPerfData));
387 auto printOptionalTime = [](std::optional<float> time,
int width,
bool trailingBar =
true) {
389 std::cout << std::format(
"{:>{}.0f}", time.value(),
width);
391 std::cout << std::format(
"{:>{}}",
"",
width);
397 std::size_t nameWidth = std::string_view(
"tool name").size();
398 for (
const auto& [prep, call] : toolPerfData)
399 nameWidth = std::max(nameWidth, prep.name.size());
402 std::string groupHeader = std::format(
"{:{}} |{:^42}|{:^52}",
403 "", nameWidth,
"prep",
"call");
404 std::string colHeader = std::format(
"{:{}} | retr(ns) | copy(ns) | call(ns) | clr(ns) | retr(ns) | copy(ns) | call(ns) | 2nd(ns) | clr(ns)",
405 "tool name", nameWidth);
407 std::cout <<
"\ntool benchmarks:" << std::endl;
408 std::cout << groupHeader << std::endl;
409 std::cout << colHeader << std::endl;
410 std::cout << std::string(colHeader.size(),
'-') << std::endl;
413 for (
const auto& [prep, call] : toolPerfData)
415 std::cout << std::format(
"{:{}} |", prep.name, nameWidth);
416 printOptionalTime(prep.timeRetrieve, 9);
417 printOptionalTime(prep.timeCopyRecord, 9);
418 printOptionalTime(prep.timeCall, 9);
419 printOptionalTime(prep.timeClear, 8);
420 printOptionalTime(call.timeRetrieve, 9);
421 printOptionalTime(call.timeCopyRecord, 9);
422 printOptionalTime(call.timeCall, 9);
423 printOptionalTime(call.timeCall2, 8);
424 printOptionalTime(call.timeClear, 8,
false);
425 std::cout << std::endl;
429 if (toolPerfData.size() > 1)
431 std::optional<float> totalPrepRetrieve, totalPrepCopyRecord, totalPrepCall, totalPrepClear;
432 std::optional<float> totalCallRetrieve, totalCallCopyRecord, totalCallCall, totalCallClear, totalRepeat;
433 for (
const auto& [prep, call] : toolPerfData)
435 if (prep.timeRetrieve)
436 totalPrepRetrieve = totalPrepRetrieve.value_or(0) + prep.timeRetrieve.value();
437 if (prep.timeCopyRecord)
438 totalPrepCopyRecord = totalPrepCopyRecord.value_or(0) + prep.timeCopyRecord.value();
440 totalPrepCall = totalPrepCall.value_or(0) + prep.timeCall.value();
442 totalPrepClear = totalPrepClear.value_or(0) + prep.timeClear.value();
443 if (call.timeRetrieve)
444 totalCallRetrieve = totalCallRetrieve.value_or(0) + call.timeRetrieve.value();
445 if (call.timeCopyRecord)
446 totalCallCopyRecord = totalCallCopyRecord.value_or(0) + call.timeCopyRecord.value();
448 totalCallCall = totalCallCall.value_or(0) + call.timeCall.value();
450 totalCallClear = totalCallClear.value_or(0) + call.timeClear.value();
452 totalRepeat = totalRepeat.value_or(0) + call.timeCall2.value();
455 std::cout << std::string(colHeader.size(),
'-') << std::endl;
456 std::cout << std::format(
"{:{}} |",
"total", nameWidth);
457 printOptionalTime(totalPrepRetrieve, 9);
458 printOptionalTime(totalPrepCopyRecord, 9);
459 printOptionalTime(totalPrepCall, 9);
460 printOptionalTime(totalPrepClear, 8);
461 printOptionalTime(totalCallRetrieve, 9);
462 printOptionalTime(totalCallCopyRecord, 9);
463 printOptionalTime(totalCallCall, 9);
464 printOptionalTime(totalRepeat, 8);
465 printOptionalTime(totalCallClear, 8,
false);
466 std::cout << std::endl;