示例#1
0
 public function testTwo()
 {
     $timer = pinba_timer_start(array('tag1' => 'value1', 'tag2' => 'value2'));
     $start = microtime(1);
     for ($i = 0; $i < 1000; ++$i) {
         md5($i);
     }
     $elapsed = microtime(1) - $start;
     $stop = pinba_timer_stop($timer);
     $this->assertTrue($stop);
     $info = pinba_timer_get_info($timer);
     $this->assertLessThan(0.1, abs($elapsed - $info['value']));
 }
示例#2
0
 public function timerGetInfo($name)
 {
     if (!array_key_exists($name, $this->timers)) {
         throw new WrongArgumentException('have no any timer with name ' . $name);
     }
     return pinba_timer_get_info($this->timers[$name]);
 }
示例#3
0
 /**
  * Returns timer data.
  *
  * @param resource $timer valid timer resource
  * @return array
  */
 public static function getInfo($timer)
 {
     if (!self::isEnabled()) {
         return;
     }
     return pinba_timer_get_info($timer);
 }
示例#4
0
 /**
  * Stops the timer
  *
  * @param string $token
  *
  * @return bool Operation success
  */
 public function stopTimer($token)
 {
     if ($this->worksWithoutPinba && $this->getClientUsed() === self::CLIENT_NONE) {
         return true;
     }
     if (!isset($this->runningTimers[$token])) {
         return false;
     }
     $timer = $this->runningTimers[$token];
     unset($this->runningTimers[$token]);
     if (!pinba_timer_get_info($timer)['started']) {
         return false;
     }
     return pinba_timer_stop($timer);
 }
示例#5
0
 /**
  * Возвращает информацию о конкретном измерении
  *
  * @param resource $resource Ресурс запущенного таймера
  *
  * @return array
  */
 public function info($resource)
 {
     if (!is_resource($resource) || !$this->isEnabled()) {
         return array();
     }
     /** @noinspection PhpUndefinedFunctionInspection */
     return pinba_timer_get_info($resource);
 }