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

Method BuildTraceEvent

Source/cmInstrumentation.cxx:1115–1167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1113}
1114
1115Json::Value cmInstrumentation::BuildTraceEvent(std::vector<uint64_t>& workers,
1116 Json::Value const& snippetData)
1117{
1118 Json::Value snippetTraceEvent;
1119
1120 // Provide a useful trace event name depending on what data is available
1121 // from the snippet.
1122 std::string nameSuffix;
1123 if (snippetData["role"] == "compile") {
1124 nameSuffix = snippetData["source"].asString();
1125 } else if (snippetData["role"] == "link") {
1126 nameSuffix = snippetData["target"].asString();
1127 } else if (snippetData["role"] == "install") {
1128 cmCMakePath workingDir(snippetData["workingDir"].asCString());
1129 nameSuffix = workingDir.GetFileName().String();
1130 } else if (snippetData["role"] == "custom") {
1131 nameSuffix = snippetData["command"].asString();
1132 } else if (snippetData["role"] == "test") {
1133 nameSuffix = snippetData["testName"].asString();
1134 }
1135 if (!nameSuffix.empty()) {
1136 snippetTraceEvent["name"] =
1137 cmStrCat(snippetData["role"].asString(), ": ", nameSuffix);
1138 } else {
1139 snippetTraceEvent["name"] = snippetData["role"].asString();
1140 }
1141
1142 snippetTraceEvent["cat"] = snippetData["role"];
1143 snippetTraceEvent["ph"] = "X";
1144 snippetTraceEvent["args"] = snippetData;
1145
1146 // Time in the Trace Event Format is stored in microseconds
1147 // but the snippet files store time in milliseconds.
1148 snippetTraceEvent["ts"] = snippetData["timeStart"].asUInt64() * 1000;
1149 snippetTraceEvent["dur"] = snippetData["duration"].asUInt64() * 1000;
1150
1151 // Assign an arbitrary PID, since this data isn't useful for the
1152 // visualization in our case.
1153 snippetTraceEvent["pid"] = 0;
1154 // Assign TID of 0 for snippets which will have other snippet data
1155 // visualized "underneath" them. (For others, start from 1.)
1156 if (snippetData["role"] == "build" || snippetData["role"] == "cmakeBuild" ||
1157 snippetData["role"] == "ctest" ||
1158 snippetData["role"] == "cmakeInstall") {
1159 snippetTraceEvent["tid"] = 0;
1160 } else {
1161 snippetTraceEvent["tid"] = static_cast<Json::Value::UInt64>(
1162 AssignTargetToTraceThread(workers, snippetData["timeStart"].asUInt64(),
1163 snippetData["duration"].asUInt64()));
1164 }
1165
1166 return snippetTraceEvent;
1167}
1168
1169size_t cmInstrumentation::AssignTargetToTraceThread(
1170 std::vector<uint64_t>& workers, uint64_t timeStart, uint64_t duration)

Callers 1

WriteTraceFileMethod · 0.95

Calls 7

asStringMethod · 0.80
asCStringMethod · 0.80
asUInt64Method · 0.80
cmStrCatFunction · 0.70
StringMethod · 0.45
GetFileNameMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected