[limb-svn] r6913 - 3.x/trunk/limb/tests_runner/src

svn at limb-project.com svn at limb-project.com
Thu Apr 10 18:22:51 MSD 2008


Author: korchasa
Date: 2008-04-10 18:22:51 +0400 (Thu, 10 Apr 2008)
New Revision: 6913
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6913

Modified:
   3.x/trunk/limb/tests_runner/src/lmbTestRunner.class.php
   3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php
Log:
-- added memory usage metric

Modified: 3.x/trunk/limb/tests_runner/src/lmbTestRunner.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestRunner.class.php	2008-04-10 13:29:55 UTC (rev 6912)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestRunner.class.php	2008-04-10 14:22:51 UTC (rev 6913)
@@ -21,8 +21,11 @@
   protected $coverage_include;
   protected $coverage_exclude;
   protected $coverage_report_dir;
+
   protected $start_time = 0;
   protected $end_time = 0;
+  protected $start_memory_usage = 0;
+  protected $end_memory_usage = 0;
 
   function setReporter($reporter)
   {
@@ -44,13 +47,13 @@
   {
     require_once(dirname(__FILE__) . '/../simpletest.inc.php');
 
-    $this->_startTimer();
+    $this->_startStatsCheck();
     $this->_startCoverage();
 
     $res = $this->_doRun($root_node, $path);
 
     $this->_endCoverage();
-    $this->_stopTimer();
+    $this->_stopStatsCheck();
     return $res;
   }
 
@@ -63,14 +66,16 @@
     return $test->run($this->_getReporter());
   }
 
-  protected function _startTimer()
+  protected function _startStatsCheck()
   {
     $this->start_time = microtime(true);
+    $this->start_memory_usage = memory_get_usage();
   }
 
-  protected function _stopTimer()
+  protected function _stopStatsCheck()
   {
     $this->end_time = microtime(true);
+    $this->end_memory_usage = memory_get_usage();
   }
 
   function getRunTime()
@@ -78,6 +83,11 @@
     return round($this->end_time - $this->start_time, 3);
   }
 
+  function getMemoryUsage()
+  {
+    return round(($this->end_memory_usage - $this->start_memory_usage) / 1024 /1024, 3);
+  }
+
   protected function _startCoverage()
   {
     if(!$this->coverage_include)
@@ -133,5 +143,3 @@
     return get_class($reporter) == 'DefaultReporter';
   }
 }
-
-

Modified: 3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php	2008-04-10 13:29:55 UTC (rev 6912)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php	2008-04-10 14:22:51 UTC (rev 6913)
@@ -60,7 +60,7 @@
   Advanced SimpleTest unit tests runner. Finds and executes unit tests within filesystem.
 Arguments:
   <file|dir> [<file1|dir1>, ... <fileN|dirN>] - a list of files/directories, globs are supported(e.g. '*')
-  KEY1=value1 [KEY2=value2, ... KEYN=valueN]  - a list of arbitrary key=value pairs which will be declared 
+  KEY1=value1 [KEY2=value2, ... KEYN=valueN]  - a list of arbitrary key=value pairs which will be declared
                                                 as constants using PHP define call
 Options:
   -h, --help                        Displays this help and exit
@@ -68,12 +68,12 @@
   -I, --include='filter1;filter2'   Sets file filters used for including test files during
                                     recursive traversal of directories.
                                     '*Test.class.php;*test.php;*Test.php' by default.
-  -G, --groups=group1[,group2]      Comma separated list of test groups defined in annotations 
-                                    tags which should be executed(e.g @group group1,group2) 
+  -G, --groups=group1[,group2]      Comma separated list of test groups defined in annotations
+                                    tags which should be executed(e.g @group group1,group2)
   -T, --tests=Foo[,Bar]             Comma separated list of test classes which should be
-                                    executed 
+                                    executed
   -M, --methods=testFoo[,testBar]   Comma separated list of test methods which should be
-                                    executed 
+                                    executed
   -C, --cover='path1;path2'         Sets paths delimitered with ';' which should be analyzed
                                     for test coverage(requires XDebug extension!)
   --cover-report=dir                Sets coverage report directory
@@ -110,7 +110,7 @@
   {
     list(, $number, $status) = explode('-', trim(file_get_contents(dirname(__FILE__) . '/../VERSION')));
     $version = "limb_unit-$number-$status";
-    
+
     if(is_dir(dirname(__FILE__) . '/.svn'))
       $version .= "-dev";
 
@@ -124,7 +124,7 @@
 
   static function getLongOpts()
   {
-    return array('help', 'version', 'include=', 'config=', 
+    return array('help', 'version', 'include=', 'config=',
                  'cover=', 'cover-report=', 'cover-exclude=',
                  'tests=', 'methods=', 'groups=');
   }
@@ -262,12 +262,13 @@
       $this->_error($e->__toString());
     }
 
-    echo $runner->getRuntime() . " sec.\n";
+    echo 'Tests time: ' . $runner->getRuntime() . " sec.\n";
+    echo 'Tests memory: ' . $runner->getMemoryUsage() . " Mb.\n";
 
     return $res;
   }
 
-  protected function _phpLint($php_code, &$error = '') 
+  protected function _phpLint($php_code, &$error = '')
   {
     $php_code = preg_replace('~<\?php~', '', $php_code);
     $php_code = preg_replace('~\?>~', '', $php_code);
@@ -277,9 +278,7 @@
     if(!$result)
       $error = ob_get_contents();
     ob_end_clean();
-    
+
     return $result;
   }
 }
-
-



More information about the limb-svn mailing list