Development

Changeset 29997

You must first sign up to be able to contribute.

Changeset 29997

Show
Ignore:
Timestamp:
06/25/10 20:17:12 (3 years ago)
Author:
slava.hatnuke
Message:

add timers

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/fpBuildPlugin/trunk/lib/task/ProjectBuildTask.class.php

    r29993 r29997  
    2121  } 
    2222 
     23  /** 
     24   * @return sfTimer 
     25   */ 
     26  private function createTimer() 
     27  { 
     28    $timer = new sfTimer(); 
     29    $timer->startTimer(); 
     30 
     31    return $timer; 
     32  } 
     33 
     34  /** 
     35   * @return sfTimer 
     36   */ 
     37  private function getTimer() 
     38  { 
     39    $timer = new sfTimer(); 
     40    $timer->startTimer(); 
     41 
     42    return $timer; 
     43  } 
     44 
     45  private function showTime(sfTimer $timer, $message = '', $afterMessage = "\n\n") 
     46  { 
     47    $timer->addTime(); 
     48     
     49    echo $message; 
     50    echo (int)$timer->getElapsedTime() . " second(s)\n"; 
     51    echo $afterMessage; 
     52  } 
     53 
    2354  protected function execute($arguments = array(), $options = array()) 
    2455  { 
     
    3465    chdir(sfConfig::get('sf_root_dir')); 
    3566 
    36     foreach (file($profile) as $task)  
     67    $totalTimer = $this->getTimer(); 
     68 
     69    foreach (file($profile) as $task) 
    3770    { 
    3871 
     72      $timer = $this->getTimer(); 
     73 
    3974      $task = trim($task); 
    40        
     75 
    4176      if(!empty($task)) 
    4277      { 
     
    4681        echo $taskName . "\n\n"; 
    4782        passthru($task, $result); 
    48         echo "\n\n"; 
     83        echo "\n"; 
     84 
     85        $this->showTime($timer); 
    4986 
    5087        if((int)$result > 0) 
    5188        { 
     89          $this->showTime($totalTimer, 'Total time: '); 
    5290          throw new Exception('`' . $taskName . '`. Running with error #ID: `'.$result.'`'); 
    5391        } 
    54          
     92 
    5593      } 
     94 
    5695    } 
     96 
     97    $this->showTime($totalTimer, 'Total time: '); 
     98 
    5799  } 
    58100}