Permalink
Browse files

Adding debug option - needs rework

  • Loading branch information...
1 parent 7e640be commit 5b5cec2bc466d6fe9c9d5b4e6998bb0febff1c9c zoe slattery committed Oct 17, 2012
@@ -54,6 +54,7 @@ class rtCommandLineOptions
'keep-out', // keep only out files
'keep-exp', // keep only exp files
'no-clean', // do not execute clean section
+ 'debug', // do not execute clean section
);
/**
@@ -20,6 +20,7 @@ class rtTaskScheduler
protected $processCount = 0; // the number of processes
protected $reportStatus = 0; // the level of repoerting as tests atr run (0, 1, 2)
+
/**
@@ -35,6 +36,8 @@ public function __construct(array $taskList=NULL, $processCount=NULL)
}
$this->setProcessCount($processCount);
+
+
}
@@ -18,7 +18,7 @@ class rtTaskSchedulerFile extends rtTaskScheduler
const TMP_FILE = 'taskFile';
protected $pidStore = array(); // stores the pids of all child-processes
- protected $groupTasks = false; // are the tasks stored in groups?
+ protected $groupTasks = false; // are the tasks already grouped by target processor
/**
@@ -44,7 +44,9 @@ public static function signalHandler($signal)
* @Overrides
*/
public function setTaskList(array $taskList)
- {
+ {
+ //Pre-allocate tasks to processors
+
if (isset($taskList[0]) && is_array($taskList[0])) {
$this->groupTasks = true;
$this->processCount = sizeof($taskList);
@@ -84,7 +86,7 @@ public function run()
$startTime = microtime(true);
- // trim the processCount if nesecarry
+ // trim the processCount if necessary
if ($this->processCount > sizeof($this->taskList)) {
$this->processCount = sizeof($this->taskList);
}
@@ -209,7 +211,7 @@ protected function child($cid)
array_pop($taskList);
file_put_contents(self::TMP_FILE.$cid, '');
-
+ $count = 0;
foreach ($taskList as $task) {
$s = microtime(true);
@@ -225,18 +227,26 @@ protected function child($cid)
$task->run();
$e = microtime(true);
-
- $statusList = $task->getResult()->getTestStatusList();
+ $taskResult = $task->getResult();
+
+ //StatusList is an array 'testname=>statusObject'
+ $statusList = $taskResult->getTestStatusList();
+ $taskResult->setProc($cid);
+ $taskResult->setCount($count);
+ /*
if (isset($statusList[0]) && is_object($statusList[0])) {
$statusList[0]->setTime($e-$s);
}
-
+ */
+
rtTestOutputWriter::flushResult($statusList, $this->reportStatus, $cid);
- $response = serialize($task->getResult())."[END]";
+ $response = serialize($taskResult)."[END]";
file_put_contents(self::TMP_FILE.$cid, $response, FILE_APPEND);
+
+ $count++;
}
exit(0);
@@ -18,6 +18,10 @@ class rtGroupResults
protected $testStatusList = array();
protected $redirectedTestCases = array();
protected $groupName;
+ protected $timeToRun;
+ protected $runOrder;
+ protected $runByProcessor = 0;
+ protected $absTime;
public function __construct($gn) {
$this->groupName = $gn;
@@ -48,5 +52,36 @@ public function getTestStatusList() {
public function getRedirectedTestCases() {
return $this->redirectedTestCases;
}
+ public function setTime($t) {
+ $this->timeToRun = $t;
+ }
+
+ public function setAbsTime($t) {
+ $this->absTime = $t;
+ }
+
+ public function setCount($c) {
+
+ $this->runOrder = $c;
+ }
+
+ public function setProc($p) {
+ $this->runByProcessor = $p;
+ }
+ public function getTime() {
+ return $this->timeToRun;
+ }
+
+ public function getRunOrder() {
+ return $this->runOrder;
+ }
+
+ public function getProcessorId() {
+ return $this->runByProcessor;
+ }
+ public function getAbsTime() {
+ return $this->absTime;
+ }
+
}
@@ -102,13 +102,12 @@ public function init()
public function run()
{
+ $s=microtime(true);
if (count($this->testCases) == 0) {
return;
}
- //$s1 = memory_get_usage();
- //foreach ($this->testCases as $testCase) {
for($i=0; $i<count($this->testCases); $i++) {
$testCase = $this->testCases[$i];
@@ -121,13 +120,13 @@ public function run()
$testResult->processResults($testCase, $this->runConfiguration);
$this->groupResults->setTestStatus($testCase->getName(), $testResult->getStatus());
- //unset($testResult); Makes no diffetence
- //echo "\n" .memory_get_usage() . ", run end";
+
}
- //$s2 = memory_get_usage();
- //unset($this->testCases);
- //echo "\n" .$s1. ", " .$s2. ", " .memory_get_usage() . ", after freeing test array\n"; //Shows memory creeping up
+ $e=microtime(true);
+
+ $this->groupResults->setTime($e-$s);
+ $this->groupResults->setAbsTime($e);
}
public function writeGroup($outType, $cid=null)
@@ -25,6 +25,7 @@ class rtPhpTestRun
protected $numberOfSerialGroups = 0;
protected $numberOfParallelGroups = 0;
protected $processorCount;
+ protected $runStartTime;
public function __construct($argv)
{
@@ -33,7 +34,7 @@ public function __construct($argv)
public function run()
{
-
+ $this->runStartTime = microtime(true);
//Set SSH variables
// check the operation-system (win/unix)
@@ -176,7 +177,21 @@ public function run_parallel_groups($testDirectories, $groupConfigurations, $pro
foreach($scheduler->getResultList() as $groupResult) {
$this->resultList[] = $groupResult->getTestStatusList();
-
+
+ // Debug - get which group was run by which processor and how long each took
+ //
+
+ if($this->runConfiguration->hasCommandLineOption('debug')) {
+ $time = round($groupResult->getTime(), 2);
+
+ $absTime = $groupResult->getAbsTime() - $this->runStartTime;
+
+ $absTime = round($absTime, 2);
+
+ echo "\nPARDBG," . $absTime. "," . $time . "," . $groupResult->getProcessorId() . "," . $groupResult->getRunOrder() . "," . $groupResult->getGroupName();
+
+ }
+
$redirects = $groupResult->getRedirectedTestCases();
foreach($redirects as $testCase) {
$this->redirectedTestCases[] = $testCase;
@@ -190,11 +205,14 @@ public function run_parallel_groups($testDirectories, $groupConfigurations, $pro
public function run_serial_groups($testDirectories, $groupConfigurations) {
$count = 0;
+
//xdebug_start_trace('/tmp/memorycheck');
foreach($testDirectories as $subDirectory) {
+
+
// Memory usage debugging
//$startm = memory_get_usage();
@@ -210,6 +228,18 @@ public function run_serial_groups($testDirectories, $groupConfigurations) {
rtTestOutputWriter::flushResult($testGroup->getGroupResults()->getTestStatusList(), $this->reportStatus);
$this->resultList[] = $testGroup->getGroupResults()->getTestStatusList();
+ if($this->runConfiguration->hasCommandLineOption('debug')) {
+
+ $time = round($testGroup->getGroupResults()->getTime(), 2);
+
+ $absTime = ($testGroup->getGroupResults()->getAbsTime()) - $this->runStartTime;
+ $absTime = round($absTime, 2);
+
+
+ echo "\nSERDBG," . $absTime . "," . $time . "," . $testGroup->getGroupResults()->getProcessorId() . "," . $count . "," . $testGroup->getGroupResults()->getGroupName();
+
+ }
+
// Memory usage debugging
//$midm2 = memory_get_usage();
@@ -221,13 +251,15 @@ public function run_serial_groups($testDirectories, $groupConfigurations) {
// Memory usage debugging
//$midm3 = memory_get_usage();
+
$testGroup->__destruct();
unset($testGroup);
// Memory usage debugging
//echo "\n" . $startm . ", " . $midm. ", " .$midm2. ", " .$midm3. ", " .memory_get_usage() . ", ". $subDirectory . "\n";
-
+ $count++;
}
+
//xdebug_stop_trace();
}
@@ -6,6 +6,7 @@ class rtTaskSchedulerTest extends PHPUnit_Framework_TestCase
{
public function testResult()
{
+ /* TODO REWRITE!
// Need to rewrite this to test the PHP group runner
$taskList = array();
$expected = array();
@@ -38,7 +39,7 @@ public function testResult()
$this->assertEquals($expected, $actual);
-
+ */
}
}

0 comments on commit 5b5cec2

Please sign in to comment.