Commit: 5b5cec2bc466d6fe9c9d5b4e6998bb0febff1c9c
Author: zoe slattery <z...@php.net> Wed, 17 Oct 2012 16:53:42 +0100
Parents: 7e640bec2f6cc190a87906316095c59e14970773
Branches: master
Link:
http://git.php.net/?p=phpruntests.git;a=commitdiff;h=5b5cec2bc466d6fe9c9d5b4e6998bb0febff1c9c
Log:
Adding debug option - needs rework
Changed paths:
M src/configuration/rtCommandLineOptions.php
M src/taskScheduler/rtTaskScheduler.php
M src/taskScheduler/rtTaskSchedulerFile.php
M src/testgroup/rtGroupResults.php
M src/testgroup/rtPhpTestGroup.php
M src/testrun/rtPhpTestRun.php
M tests/rtTaskSchedulerTest.php
diff --git a/src/configuration/rtCommandLineOptions.php
b/src/configuration/rtCommandLineOptions.php
index eec5f39..7f11481 100644
--- a/src/configuration/rtCommandLineOptions.php
+++ b/src/configuration/rtCommandLineOptions.php
@@ -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
);
/**
diff --git a/src/taskScheduler/rtTaskScheduler.php
b/src/taskScheduler/rtTaskScheduler.php
index cf1b9f1..2d70f24 100644
--- a/src/taskScheduler/rtTaskScheduler.php
+++ b/src/taskScheduler/rtTaskScheduler.php
@@ -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 @@ class rtTaskScheduler
}
$this->setProcessCount($processCount);
+
+
}
diff --git a/src/taskScheduler/rtTaskSchedulerFile.php
b/src/taskScheduler/rtTaskSchedulerFile.php
index 1831eba..dabe233 100644
--- a/src/taskScheduler/rtTaskSchedulerFile.php
+++ b/src/taskScheduler/rtTaskSchedulerFile.php
@@ -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 @@ class rtTaskSchedulerFile extends rtTaskScheduler
* @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 @@ class rtTaskSchedulerFile extends rtTaskScheduler
$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 @@ class rtTaskSchedulerFile extends rtTaskScheduler
array_pop($taskList);
file_put_contents(self::TMP_FILE.$cid, '');
-
+ $count = 0;
foreach ($taskList as $task) {
$s = microtime(true);
@@ -225,18 +227,26 @@ class rtTaskSchedulerFile extends rtTaskScheduler
$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);
diff --git a/src/testgroup/rtGroupResults.php b/src/testgroup/rtGroupResults.php
index fdbf5aa..26e9f90 100644
--- a/src/testgroup/rtGroupResults.php
+++ b/src/testgroup/rtGroupResults.php
@@ -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 @@ class rtGroupResults
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;
+ }
+
}
\ No newline at end of file
diff --git a/src/testgroup/rtPhpTestGroup.php b/src/testgroup/rtPhpTestGroup.php
index e4724db..012560d 100644
--- a/src/testgroup/rtPhpTestGroup.php
+++ b/src/testgroup/rtPhpTestGroup.php
@@ -102,13 +102,12 @@ class rtPhpTestGroup extends rtTask implements
rtTaskInterface
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 @@ class rtPhpTestGroup extends rtTask implements
rtTaskInterface
$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)
diff --git a/src/testrun/rtPhpTestRun.php b/src/testrun/rtPhpTestRun.php
index b03a9a8..b95a987 100644
--- a/src/testrun/rtPhpTestRun.php
+++ b/src/testrun/rtPhpTestRun.php
@@ -25,6 +25,7 @@ class rtPhpTestRun
protected $numberOfSerialGroups = 0;
protected $numberOfParallelGroups = 0;
protected $processorCount;
+ protected $runStartTime;
public function __construct($argv)
{
@@ -33,7 +34,7 @@ class rtPhpTestRun
public function run()
{
-
+ $this->runStartTime = microtime(true);
//Set SSH variables
// check the operation-system (win/unix)
@@ -176,7 +177,21 @@ class rtPhpTestRun
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 @@ class rtPhpTestRun
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 @@ class rtPhpTestRun
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 @@ class rtPhpTestRun
// 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();
}
diff --git a/tests/rtTaskSchedulerTest.php b/tests/rtTaskSchedulerTest.php
index a1b8768..fd71bc0 100644
--- a/tests/rtTaskSchedulerTest.php
+++ b/tests/rtTaskSchedulerTest.php
@@ -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 @@ class rtTaskSchedulerTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $actual);
-
+ */
}
}
--
PHP Quality Assurance Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php