ENH: ctest now writes time cost data to a file after a test set is run, and uses these time costs to schedule the processes the next time ctest is run in that build tree.
This commit is contained in:
parent
883338584f
commit
a516040579
|
@ -30,11 +30,9 @@ cmCTestMultiProcessHandler::cmCTestMultiProcessHandler()
|
||||||
// Set the tests
|
// Set the tests
|
||||||
void
|
void
|
||||||
cmCTestMultiProcessHandler::SetTests(TestMap& tests,
|
cmCTestMultiProcessHandler::SetTests(TestMap& tests,
|
||||||
TestCostMap& testCosts,
|
|
||||||
PropertiesMap& properties)
|
PropertiesMap& properties)
|
||||||
{
|
{
|
||||||
this->Tests = tests;
|
this->Tests = tests;
|
||||||
this->TestCosts = testCosts;
|
|
||||||
this->Properties = properties;
|
this->Properties = properties;
|
||||||
this->Total = this->Tests.size();
|
this->Total = this->Tests.size();
|
||||||
// set test run map to false for all
|
// set test run map to false for all
|
||||||
|
@ -44,6 +42,8 @@ cmCTestMultiProcessHandler::SetTests(TestMap& tests,
|
||||||
this->TestRunningMap[i->first] = false;
|
this->TestRunningMap[i->first] = false;
|
||||||
this->TestFinishMap[i->first] = false;
|
this->TestFinishMap[i->first] = false;
|
||||||
}
|
}
|
||||||
|
this->ReadCostData();
|
||||||
|
this->CreateTestCostList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the max number of tests that can be run at the same time.
|
// Set the max number of tests that can be run at the same time.
|
||||||
|
@ -271,12 +271,63 @@ bool cmCTestMultiProcessHandler::CheckOutput()
|
||||||
this->TestRunningMap[test] = false;
|
this->TestRunningMap[test] = false;
|
||||||
this->RunningTests.erase(p);
|
this->RunningTests.erase(p);
|
||||||
this->WriteCheckpoint(test);
|
this->WriteCheckpoint(test);
|
||||||
|
this->WriteCostData(test, p->GetTestResults().ExecutionTime);
|
||||||
this->RunningCount -= GetProcessorsUsed(test);
|
this->RunningCount -= GetProcessorsUsed(test);
|
||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
void cmCTestMultiProcessHandler::ReadCostData()
|
||||||
|
{
|
||||||
|
std::string fname = this->CTest->GetBinaryDir()
|
||||||
|
+ "/Testing/Temporary/CTestCostData.txt";
|
||||||
|
|
||||||
|
if(cmSystemTools::FileExists(fname.c_str(), true)
|
||||||
|
&& this->ParallelLevel > 1)
|
||||||
|
{
|
||||||
|
std::ifstream fin;
|
||||||
|
fin.open(fname.c_str());
|
||||||
|
std::string line;
|
||||||
|
while(std::getline(fin, line))
|
||||||
|
{
|
||||||
|
std::vector<cmsys::String> parts =
|
||||||
|
cmSystemTools::SplitString(line.c_str(), ' ');
|
||||||
|
|
||||||
|
int index = atoi(parts[0].c_str());
|
||||||
|
float cost = atof(parts[1].c_str());
|
||||||
|
if(this->Properties[index] && this->Properties[index]->Cost == 0)
|
||||||
|
{
|
||||||
|
this->Properties[index]->Cost = cost;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fin.close();
|
||||||
|
}
|
||||||
|
cmSystemTools::RemoveFile(fname.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
void cmCTestMultiProcessHandler::CreateTestCostList()
|
||||||
|
{
|
||||||
|
for(TestMap::iterator i = this->Tests.begin();
|
||||||
|
i != this->Tests.end(); ++i)
|
||||||
|
{
|
||||||
|
this->TestCosts[this->Properties[i->first]->Cost].insert(i->first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
void cmCTestMultiProcessHandler::WriteCostData(int index, float cost)
|
||||||
|
{
|
||||||
|
std::string fname = this->CTest->GetBinaryDir()
|
||||||
|
+ "/Testing/Temporary/CTestCostData.txt";
|
||||||
|
std::fstream fout;
|
||||||
|
fout.open(fname.c_str(), std::ios::app);
|
||||||
|
fout << index << " " << cost << "\n";
|
||||||
|
fout.close();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
void cmCTestMultiProcessHandler::WriteCheckpoint(int index)
|
void cmCTestMultiProcessHandler::WriteCheckpoint(int index)
|
||||||
{
|
{
|
||||||
|
@ -288,6 +339,7 @@ void cmCTestMultiProcessHandler::WriteCheckpoint(int index)
|
||||||
fout.close();
|
fout.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
void cmCTestMultiProcessHandler::MarkFinished()
|
void cmCTestMultiProcessHandler::MarkFinished()
|
||||||
{
|
{
|
||||||
std::string fname = this->CTest->GetBinaryDir()
|
std::string fname = this->CTest->GetBinaryDir()
|
||||||
|
@ -295,7 +347,7 @@ void cmCTestMultiProcessHandler::MarkFinished()
|
||||||
cmSystemTools::RemoveFile(fname.c_str());
|
cmSystemTools::RemoveFile(fname.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
//For ShowOnly mode
|
//For ShowOnly mode
|
||||||
void cmCTestMultiProcessHandler::PrintTestList()
|
void cmCTestMultiProcessHandler::PrintTestList()
|
||||||
{
|
{
|
||||||
|
@ -330,7 +382,7 @@ void cmCTestMultiProcessHandler::PrintTestList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
void cmCTestMultiProcessHandler::CheckResume()
|
void cmCTestMultiProcessHandler::CheckResume()
|
||||||
{
|
{
|
||||||
std::string fname = this->CTest->GetBinaryDir()
|
std::string fname = this->CTest->GetBinaryDir()
|
||||||
|
|
|
@ -37,8 +37,7 @@ public:
|
||||||
|
|
||||||
cmCTestMultiProcessHandler();
|
cmCTestMultiProcessHandler();
|
||||||
// Set the tests
|
// Set the tests
|
||||||
void SetTests(TestMap& tests, TestCostMap& testCosts,
|
void SetTests(TestMap& tests, PropertiesMap& properties);
|
||||||
PropertiesMap& properties);
|
|
||||||
// Set the max number of tests that can be run at the same time.
|
// Set the max number of tests that can be run at the same time.
|
||||||
void SetParallelLevel(size_t);
|
void SetParallelLevel(size_t);
|
||||||
void RunTests();
|
void RunTests();
|
||||||
|
@ -70,6 +69,9 @@ protected:
|
||||||
bool StartTest(int test);
|
bool StartTest(int test);
|
||||||
// Mark the checkpoint for the given test
|
// Mark the checkpoint for the given test
|
||||||
void WriteCheckpoint(int index);
|
void WriteCheckpoint(int index);
|
||||||
|
void WriteCostData(int index, float cost);
|
||||||
|
void ReadCostData();
|
||||||
|
void CreateTestCostList();
|
||||||
// Removes the checkpoint file
|
// Removes the checkpoint file
|
||||||
void MarkFinished();
|
void MarkFinished();
|
||||||
void EraseTest(int index);
|
void EraseTest(int index);
|
||||||
|
|
|
@ -1010,7 +1010,6 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
cmCTestMultiProcessHandler::TestMap tests;
|
cmCTestMultiProcessHandler::TestMap tests;
|
||||||
cmCTestMultiProcessHandler::TestCostMap testCosts;
|
|
||||||
cmCTestMultiProcessHandler::PropertiesMap properties;
|
cmCTestMultiProcessHandler::PropertiesMap properties;
|
||||||
|
|
||||||
for (ListOfTests::iterator it = this->TestList.begin();
|
for (ListOfTests::iterator it = this->TestList.begin();
|
||||||
|
@ -1037,9 +1036,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
|
||||||
}
|
}
|
||||||
tests[it->Index] = depends;
|
tests[it->Index] = depends;
|
||||||
properties[it->Index] = &*it;
|
properties[it->Index] = &*it;
|
||||||
testCosts[p.Cost].insert(p.Index);
|
|
||||||
}
|
}
|
||||||
parallel.SetTests(tests, testCosts, properties);
|
parallel.SetTests(tests, properties);
|
||||||
parallel.SetPassFailVectors(&passed, &failed);
|
parallel.SetPassFailVectors(&passed, &failed);
|
||||||
this->TestResults.clear();
|
this->TestResults.clear();
|
||||||
parallel.SetTestResults(&this->TestResults);
|
parallel.SetTestResults(&this->TestResults);
|
||||||
|
|
Loading…
Reference in New Issue