268 using namespace asg::msgUserCode;
270 auto eventReader = makeEventReader();
273 std::vector<ToolData> toolDataVec;
274 for (
const auto& testDefinition : testDefinitions)
276 if (testDefinition.xAODToolCaller !=
nullptr)
279 toolData.name = testDefinition.name;
280 toolData.xAODToolCaller = testDefinition.xAODToolCaller;
281 toolData.noRepeatCall = testDefinition.noRepeatCall;
282 toolDataVec.push_back(std::move(toolData));
287 if (!testDefinitions.empty() && testDefinitions[0].tool)
288 evtStore = &*testDefinitions[0].tool->evtStore();
294 throw std::runtime_error (
"ColumnarPhysLiteTest: numberOfEvents == 0");
296 std::uint64_t entry = 0;
303 const auto startTime = std::chrono::high_resolution_clock::now();
304 for (; (std::chrono::high_resolution_clock::now() - startTime) < userConfiguration.
targetTime; ++entry)
309 if (eventReader->hasClearStore())
311 static const std::string prepPostfix =
"Prep";
312 for (
auto& toolData : toolDataVec)
314 for (
auto& toolData : toolDataVec)
316 for (
auto& toolData : toolDataVec)
318 for (
auto& toolData : toolDataVec)
320 eventReader->clearStore();
322 static const std::string callPostfix =
"Call";
323 for (
auto& toolData : toolDataVec)
325 for (
auto& toolData : toolDataVec)
327 for (
auto& toolData : toolDataVec)
335 if (userConfiguration.
runToolTwice && !toolData.noRepeatCall)
340 for (
auto& toolData : toolDataVec)
342 if (eventReader->hasClearStore())
343 eventReader->clearStore();
345 std::cout <<
"Total entries read: " << entry << std::endl;
346 const float emptyTime = benchmarkEmpty.
getEntryTime(0).value();
348 eventReader->printBenchmarkTable(emptyTime);
351 std::vector<std::pair<ToolPerfData, ToolPerfData>> toolPerfData;
352 for (
auto& toolData : toolDataVec)
355 prepPerfData.
name = toolData.name;
356 if (eventReader->hasClearStore()) {
357 prepPerfData.
timeRetrieve = toolData.benchmarkRetrieve[0].getEntryTime(emptyTime);
358 prepPerfData.
timeCopyRecord = toolData.benchmarkCopyRecord[0].getEntryTime(emptyTime);
359 prepPerfData.
timeCall = toolData.benchmarkCall[0].getEntryTime(emptyTime);
360 prepPerfData.
timeClear = toolData.benchmarkClear[0].getEntryTime(emptyTime);
361 toolData.benchmarkRetrieve[0].setSilence();
362 toolData.benchmarkCopyRecord[0].setSilence();
363 toolData.benchmarkCall[0].setSilence();
364 toolData.benchmarkClear[0].setSilence();
368 callPerfData.
name = toolData.name;
369 callPerfData.
timeRetrieve = toolData.benchmarkRetrieve[1].getEntryTime(emptyTime);
370 callPerfData.
timeCopyRecord = toolData.benchmarkCopyRecord[1].getEntryTime(emptyTime);
371 callPerfData.
timeCall = toolData.benchmarkCall[1].getEntryTime(emptyTime);
372 callPerfData.
timeClear = toolData.benchmarkClear[1].getEntryTime(emptyTime);
374 callPerfData.
timeCall2 = toolData.benchmarkCall[2].getEntryTime(emptyTime);
375 toolData.benchmarkCall[2].setSilence();
377 toolData.benchmarkRetrieve[1].setSilence();
378 toolData.benchmarkCopyRecord[1].setSilence();
379 toolData.benchmarkCall[1].setSilence();
380 toolData.benchmarkClear[1].setSilence();
382 toolPerfData.emplace_back(std::move(prepPerfData), std::move(callPerfData));
386 auto printOptionalTime = [](std::optional<float> time,
int width,
bool trailingBar =
true) {
388 std::cout << std::format(
"{:>{}.0f}", time.value(),
width);
390 std::cout << std::format(
"{:>{}}",
"",
width);
396 std::size_t nameWidth = std::string_view(
"tool name").size();
397 for (
const auto& [prep, call] : toolPerfData)
398 nameWidth = std::max(nameWidth, prep.name.size());
401 std::string groupHeader = std::format(
"{:{}} |{:^42}|{:^52}",
402 "", nameWidth,
"prep",
"call");
403 std::string colHeader = std::format(
"{:{}} | retr(ns) | copy(ns) | call(ns) | clr(ns) | retr(ns) | copy(ns) | call(ns) | 2nd(ns) | clr(ns)",
404 "tool name", nameWidth);
406 std::cout <<
"\ntool benchmarks:" << std::endl;
407 std::cout << groupHeader << std::endl;
408 std::cout << colHeader << std::endl;
409 std::cout << std::string(colHeader.size(),
'-') << std::endl;
412 for (
const auto& [prep, call] : toolPerfData)
414 std::cout << std::format(
"{:{}} |", prep.name, nameWidth);
415 printOptionalTime(prep.timeRetrieve, 9);
416 printOptionalTime(prep.timeCopyRecord, 9);
417 printOptionalTime(prep.timeCall, 9);
418 printOptionalTime(prep.timeClear, 8);
419 printOptionalTime(call.timeRetrieve, 9);
420 printOptionalTime(call.timeCopyRecord, 9);
421 printOptionalTime(call.timeCall, 9);
422 printOptionalTime(call.timeCall2, 8);
423 printOptionalTime(call.timeClear, 8,
false);
424 std::cout << std::endl;
428 if (toolPerfData.size() > 1)
430 std::optional<float> totalPrepRetrieve, totalPrepCopyRecord, totalPrepCall, totalPrepClear;
431 std::optional<float> totalCallRetrieve, totalCallCopyRecord, totalCallCall, totalCallClear, totalRepeat;
432 for (
const auto& [prep, call] : toolPerfData)
434 if (prep.timeRetrieve)
435 totalPrepRetrieve = totalPrepRetrieve.value_or(0) + prep.timeRetrieve.value();
436 if (prep.timeCopyRecord)
437 totalPrepCopyRecord = totalPrepCopyRecord.value_or(0) + prep.timeCopyRecord.value();
439 totalPrepCall = totalPrepCall.value_or(0) + prep.timeCall.value();
441 totalPrepClear = totalPrepClear.value_or(0) + prep.timeClear.value();
442 if (call.timeRetrieve)
443 totalCallRetrieve = totalCallRetrieve.value_or(0) + call.timeRetrieve.value();
444 if (call.timeCopyRecord)
445 totalCallCopyRecord = totalCallCopyRecord.value_or(0) + call.timeCopyRecord.value();
447 totalCallCall = totalCallCall.value_or(0) + call.timeCall.value();
449 totalCallClear = totalCallClear.value_or(0) + call.timeClear.value();
451 totalRepeat = totalRepeat.value_or(0) + call.timeCall2.value();
454 std::cout << std::string(colHeader.size(),
'-') << std::endl;
455 std::cout << std::format(
"{:{}} |",
"total", nameWidth);
456 printOptionalTime(totalPrepRetrieve, 9);
457 printOptionalTime(totalPrepCopyRecord, 9);
458 printOptionalTime(totalPrepCall, 9);
459 printOptionalTime(totalPrepClear, 8);
460 printOptionalTime(totalCallRetrieve, 9);
461 printOptionalTime(totalCallCopyRecord, 9);
462 printOptionalTime(totalCallCall, 9);
463 printOptionalTime(totalRepeat, 8);
464 printOptionalTime(totalCallClear, 8,
false);
465 std::cout << std::endl;