9 namespace Fossology\Lib\Util;
 
   15   const DEFAULT_WATCH = 
'default';
 
   25   public function __construct(Logger $logger)
 
   27     $this->logger = $logger;
 
   29     $this->startTime = $this->getTimestamp();
 
   30     $this->watchTimes = array(self::DEFAULT_WATCH => $this->startTime);
 
   38   public function tic($watch = self::DEFAULT_WATCH)
 
   40     $this->watchTimes[$watch] = $this->getTimestamp();
 
   47   public function toc($text, $watch = self::DEFAULT_WATCH)
 
   49     if (! array_key_exists($watch, $this->watchTimes)) {
 
   50       $watch = self::DEFAULT_WATCH;
 
   51       $text .= 
" using watch '$watch'";
 
   52     } 
else if (empty($text)) {
 
   53       $text = 
"Using watch '$watch'";
 
   64     $endTime = $this->getTimestamp();
 
   75     $this->logger->debug(sprintf(
"%s (%.3fms)", $text, ($endTime - $startTime) * 1000));
 
   76     $this->startTime = $endTime;
 
   79   protected function getTimestamp()
 
   81     return microtime(
true);
 
tic($watch=self::DEFAULT_WATCH)
start stopwatch timer
toc($text, $watch=self::DEFAULT_WATCH)
logWithStartTime($text, $startTime)
logWithStartAndEndTime($text, $startTime, $endTime)