/**
  * Stops the timer.
  *
  * @return void
  */
 public function stop()
 {
     if ($this->_pinbaTimer != null) {
         pinba_timer_stop($this->_pinbaTimer);
         $this->_pinbaTimer = null;
     }
 }
Пример #2
0
 /**
  * Stops the timer.
  *
  * @param resource $timer valid timer resource.
  * @return bool Returns true on success and false on failure (if the timer has already been stopped).
  */
 public static function stop($timer)
 {
     if (!self::isEnabled()) {
         return;
     }
     return pinba_timer_stop($timer);
 }
Пример #3
0
 public function __call($method, $args)
 {
     $tags = array('group' => 'redis', 'op' => $method);
     $timer = pinba_timer_start($tags);
     $result = call_user_func_array(array($this->Redis, $method), $args);
     pinba_timer_stop($timer);
     return $result;
 }
Пример #4
0
 /**
  * Останавливает таймер
  * https://github.com/tony2001/pinba_engine/wiki/PHP-extension#pinba_timers_stop
  * @param resource $resource
  * @return bool|null
  */
 public static function stop($resource)
 {
     if (!self::isEnabled()) {
         return null;
     }
     /** @noinspection PhpUndefinedFunctionInspection */
     return pinba_timer_stop($resource);
 }
Пример #5
0
 public function timerStop($name)
 {
     if ($this->isTreeLogEnabled()) {
         array_pop($this->queue);
     }
     if (!array_key_exists($name, $this->timers)) {
         throw new WrongArgumentException('have no any timer with name ' . $name);
     }
     pinba_timer_stop($this->timers[$name]);
     unset($this->timers[$name]);
     return $this;
 }
 public static function timerStop($options)
 {
     if (self::init()) {
         $options = self::noramlizeOptions($options);
         $timerName = self::getTimerName($options);
         if (isset(self::$timer[$timerName])) {
             $timer = array_pop(self::$timer[$timerName]);
             return pinba_timer_stop($timer);
         }
     }
     return false;
 }
Пример #7
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']));
 }
Пример #8
0
<?php

/**
* A sample php file that uses the pinba php extension
*/
// start time measurement asap
$starttime = microtime(true);
include 'prtbfr.php';
include 'pinba.php';
include 'pinbafunctions.php';
// this is optional - if omitted time measurement will start when pinba.php file is included
pinba::init($starttime);
// do some stuff here ...
// measure some operation
$t = pinba_timer_start(array("group" => "mysql", "server" => "dbs2", "operation" => "select"));
$result = mysql_query("SELECT ...", $connection);
pinba_timer_stop($t);
// that's all folks!
Пример #9
0
 public function stop()
 {
     if ($this->pinbaTimer) {
         pinba_timer_stop($this->pinbaTimer);
     }
 }
Пример #10
0
require_once __DIR__ . '/../vendor/autoload.php';
if (class_exists('pinba', false)) {
    pinba::ini_set_auto_flush(true);
    pinba::ini_set_enabled(1);
    pinba::ini_set_server('127.0.0.1:3300');
}
var_dump(ini_set('pinba.enabled', 1));
var_dump(ini_set('pinba.server', '127.0.0.1:3300'));
$file = file_get_contents(__FILE__);
$timer = pinba_timer_start(array('action' => 'gzencode', 'tag2' => 'value2'));
$start = microtime(1);
gzencode($file);
$elapsed = microtime(1) - $start;
$stop = pinba_timer_stop($timer);
$timer = pinba_timer_start(array('action' => 'md5', 'tag2' => 'value2'));
$start = microtime(1);
for ($i = 0; $i < 1000; ++$i) {
    md5($i);
}
$elapsed = microtime(1) - $start;
$stop = pinba_timer_stop($timer);
$timer = pinba_timer_start(array('action' => 'serialize', 'tag2' => 'value3'));
$start = microtime(1);
for ($i = 0; $i < 1000; ++$i) {
    serialize($_SERVER);
}
$elapsed = microtime(1) - $start;
$stop = pinba_timer_stop($timer);
header("Content-Type: text/plain");
echo $file;
Пример #11
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);
 }
Пример #12
0
 /**
  * Останавливает таймер
  * https://github.com/tony2001/pinba_engine/wiki/PHP-extension#pinba_timers_stop
  *
  * @param resource $resource Ресурс запущенного таймера
  *
  * @return bool|null
  */
 public function stop($resource)
 {
     if (!is_resource($resource) || !$this->isEnabled()) {
         return true;
     }
     /** @noinspection PhpUndefinedFunctionInspection */
     return pinba_timer_stop($resource);
 }