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

Method CollectTimingData

Source/cmInstrumentation.cxx:349–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347}
348
349int cmInstrumentation::CollectTimingData(cmInstrumentationQuery::Hook hook)
350{
351 // Don't run collection if hook is disabled
352 if (hook != cmInstrumentationQuery::Hook::Manual && !this->HasHook(hook)) {
353 return 0;
354 }
355
356 this->LockIndexing();
357
358 // Touch index file immediately to claim snippets
359 std::string suffix_time = ComputeSuffixTime();
360 std::string const& index_name = cmStrCat("index-", suffix_time, ".json");
361 std::string index_path = cmStrCat(this->dataDir, "/index/", index_name);
362 cmSystemTools::Touch(index_path, true);
363
364 // Gather Snippets
365 using snippet = std::pair<std::string, std::string>;
366 std::vector<snippet> files;
367 cmsys::Directory d;
368 std::string last_index_name =
369 this->GetFileByTimestamp(LatestOrOldest::Latest, "index", index_name);
370 std::string last_index_path =
371 cmStrCat(this->dataDir, "/index/", last_index_name);
372 if (d.Load(this->dataDir)) {
373 for (unsigned int i = 0; i < d.GetNumberOfFiles(); i++) {
374 std::string fpath = d.GetFilePath(i);
375 std::string fname = d.GetFile(i);
376 if (fname.rfind('.', 0) == 0 || d.FileIsDirectory(i)) {
377 continue;
378 }
379 files.push_back(snippet(std::move(fname), std::move(fpath)));
380 }
381 }
382
383 // Build Json Object
384 Json::Value index(Json::objectValue);
385 index["snippets"] = Json::arrayValue;
386 index["hook"] = cmInstrumentationQuery::HookString[hook];
387 index["dataDir"] = this->dataDir;
388 index["buildDir"] = this->binaryDir;
389 if (this->HasOption(
390 cmInstrumentationQuery::Option::StaticSystemInformation)) {
391 this->InsertStaticSystemInformation(index);
392 }
393
394 for (auto const& file : files) {
395 if (last_index_name.empty()) {
396 index["snippets"].append(file.first);
397 } else {
398 int compare;
399 cmSystemTools::FileTimeCompare(file.second, last_index_path, &compare);
400 if (compare == 1) {
401 index["snippets"].append(file.first);
402 }
403 }
404 }
405
406 // Parse snippets into the Google trace file

Callers 11

SpawnBuildDaemonMethod · 0.95
ExecuteTestsMethod · 0.80
do_installFunction · 0.80
mainFunction · 0.80
GenerateMethod · 0.80
BuildMethod · 0.80
WorkflowMethod · 0.80
GenerateCTestXMLMethod · 0.80
ExecuteConfigureMethod · 0.80
ProcessHandlerMethod · 0.80

Calls 15

HasHookMethod · 0.95
LockIndexingMethod · 0.95
GetFileByTimestampMethod · 0.95
HasOptionMethod · 0.95
WriteTraceFileMethod · 0.95
PrepareDataForCDashMethod · 0.95
RemoveOldFilesMethod · 0.95
moveFunction · 0.85
rfindMethod · 0.80
FileIsDirectoryMethod · 0.80

Tested by 5

ExecuteTestsMethod · 0.64
mainFunction · 0.64
GenerateCTestXMLMethod · 0.64
ExecuteConfigureMethod · 0.64
ProcessHandlerMethod · 0.64