Changeset 129

Show
Ignore:
Timestamp:
03/04/08 00:38:36 (10 months ago)
Author:
iteman
Message:

- Added support for auto adjusting scan interval. (Ticket #14)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/Stagehand/TestRunner/AlterationMonitor.php

    r127 r129  
    5454{ 
    5555 
     56    // {{{ constants 
     57 
     58    const SCAN_INTERVAL_MIN = 5; 
     59 
     60    // }}} 
    5661    // {{{ properties 
    5762 
     
    8489                                      '!^#.+#$!' 
    8590                                      ); 
     91    private $_scanInterval = self::SCAN_INTERVAL_MIN; 
    8692 
    8793    /**#@-*/ 
     
    121127Waiting for changes in the directory [ {$this->_directory} ] ... 
    122128"; 
     129 
    123130            $this->_waitForChanges(); 
    124131 
     
    167174 
    168175        while (true) { 
    169             sleep(5); 
     176            sleep($this->_scanInterval); 
    170177            clearstatcache(); 
    171178 
    172179            try { 
    173180                $this->_currentElements = array(); 
     181                $startTime = time(); 
    174182                $this->_collectElements($this->_directory); 
     183                $endTime = time(); 
     184                $elapsedTime = $endTime - $startTime; 
     185                if ($elapsedTime > self::SCAN_INTERVAL_MIN) { 
     186                    $this->_scanInterval = $elapsedTime; 
     187                } 
    175188            } catch (Stagehand_TestRunner_Exception $e) { 
    176189                return;