MCPcopy Create free account
hub / github.com/Kitware/CMake / InstrumentCommand

Method InstrumentCommand

Source/cmInstrumentation.cxx:627–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

625}
626
627int cmInstrumentation::InstrumentCommand(
628 std::string command_type, std::vector<std::string> const& command,
629 std::function<int()> const& callback,
630 cm::optional<std::map<std::string, std::string>> data,
631 cm::optional<std::map<std::string, std::string>> arrayData,
632 LoadQueriesAfter reloadQueriesAfterCommand)
633{
634
635 // Always begin gathering data for configure in case cmake_instrumentation
636 // command creates a query
637 if (!this->hasQuery && reloadQueriesAfterCommand == LoadQueriesAfter::No) {
638 return callback();
639 }
640
641 // Store command info
642 Json::Value root(Json::objectValue);
643 Json::Value commandInfo(Json::objectValue);
644 std::string command_str = GetCommandStr(command);
645
646 if (!command_str.empty()) {
647 root["command"] = command_str;
648 }
649
650 // Pre-Command
651 auto steady_start = std::chrono::steady_clock::now();
652 auto system_start = std::chrono::system_clock::now();
653 double preConfigureMemory = 0;
654 double preConfigureLoad = 0;
655 if (this->HasOption(
656 cmInstrumentationQuery::Option::DynamicSystemInformation)) {
657 this->InsertDynamicSystemInformation(root, "before");
658 } else if (reloadQueriesAfterCommand == LoadQueriesAfter::Yes) {
659 this->GetDynamicSystemInformation(preConfigureMemory, preConfigureLoad);
660 }
661
662 // Execute Command
663 int ret = callback();
664
665 // Exit early if configure didn't generate a query
666 if (reloadQueriesAfterCommand == LoadQueriesAfter::Yes) {
667 this->LoadQueries();
668 if (!this->HasQuery()) {
669 return ret;
670 }
671 if (this->HasOption(
672 cmInstrumentationQuery::Option::DynamicSystemInformation)) {
673 root["dynamicSystemInformation"] = Json::objectValue;
674 root["dynamicSystemInformation"]["beforeHostMemoryUsed"] =
675 preConfigureMemory;
676 root["dynamicSystemInformation"]["beforeCPULoadAverage"] =
677 preConfigureLoad;
678 }
679 }
680
681 // Post-Command
682 this->InsertTimingData(root, steady_start, system_start);
683 if (this->HasOption(
684 cmInstrumentationQuery::Option::DynamicSystemInformation)) {

Callers 7

ExecuteTestsMethod · 0.80
do_installFunction · 0.80
ActualConfigureMethod · 0.80
GenerateMethod · 0.80
BuildMethod · 0.80
RunMethod · 0.80

Calls 15

HasOptionMethod · 0.95
LoadQueriesMethod · 0.95
HasQueryMethod · 0.95
InsertTimingDataMethod · 0.95
GetFileByTimestampMethod · 0.95
ComputeSuffixHashMethod · 0.95
ComputeSuffixTimeMethod · 0.95
has_valueMethod · 0.80
valueMethod · 0.80

Tested by 2

ExecuteTestsMethod · 0.64
RunMethod · 0.64