コード例 #1
0
ファイル: ConnectionPanel.php プロジェクト: janmarek/doctrine
 public function stopQuery()
 {
     if ($this->explainRunning) {
         return;
     }
     $keys = array_keys($this->queries);
     $key = end($keys);
     $this->queries[$key][self::TIME] = Debugger::timer('doctrine');
     $this->totalTime += $this->queries[$key][self::TIME];
     // get EXPLAIN for SELECT queries
     if ($this->doExplains) {
         if ($this->connection === NULL) {
             throw new \Nette\InvalidStateException('You must set a Doctrine\\DBAL\\Connection to get EXPLAIN.');
         }
         $query = $this->queries[$key][self::SQL];
         if (strtoupper(substr(ltrim($query), 0, 6)) !== 'SELECT') {
             // only SELECTs are supported
             return;
         }
         // prevent logging explains & infinite recursion
         $this->explainRunning = TRUE;
         $params = $this->queries[$key][self::PARAMS];
         $types = $this->queries[$key][self::TYPES];
         $stmt = $this->connection->executeQuery('EXPLAIN ' . $query, $params, $types);
         $this->queries[$key][self::EXPLAIN] = $stmt->fetchAll();
         $this->explainRunning = FALSE;
     }
 }
コード例 #2
0
ファイル: Panel.php プロジェクト: norbe/framework
	public function stopQuery()
	{
		$keys = array_keys($this->queries);
		$key = end($keys);
		$this->queries[$key][2] = Debugger::timer('doctrine');
		$this->totalTime += $this->queries[$key][2];
	}
コード例 #3
0
 public function shutdown($response)
 {
     parent::shutdown($response);
     if ($this->getHttpRequest()->getUrl()->path != '/healthy-check') {
         $elapsed = \Nette\Diagnostics\Debugger::timer('global');
         // Log Valid Response
         $data = array('elapsed' => $elapsed, 'upd_process_id' => 'BasePresenter::shutdown()');
         if ($this->lastLogItem) {
             $this->logger->updateLogVisit($this->lastLogItem->id, $data);
         }
     }
 }
コード例 #4
0
ファイル: Curl.php プロジェクト: shailendra9/Google-2
 public function makeRequest(Google_Http_Request $request)
 {
     $this->onRequest($request);
     Debugger::timer(__CLASS__);
     try {
         $res = parent::makeRequest($request);
         $this->onSuccess($request, Debugger::timer(__CLASS__));
         $this->onResponse($request);
     } catch (Google_Exception $e) {
         $this->onError($request, Debugger::timer(__CLASS__), $e);
         $this->onResponse($request);
         throw $e;
     }
     return $res;
 }
コード例 #5
0
ファイル: Stopwatch.php プロジェクト: peterzadori/movi
 public static function stop($name)
 {
     $time = Debugger::timer($name);
     self::$timers[$name] = $time;
 }
コード例 #6
0
ファイル: index.php プロジェクト: Vrtak-CZ/NJLogParser
/*if (file_exists(__DIR__."/db.sqlite")) {
	copy(__DIR__."/db.sqlite", __DIR__."/backup/".date("Y-m-d_H-i-s-").substr(microtime(TRUE)-time(), 2, 4).".sqlite");
}
$connection = new \Nette\Database\Connection('sqlite:' . __DIR__ . '/db.sqlite');
\Nette\Database\Helpers::loadFromFile($connection, __DIR__ . '/db.structure.sqlite.sql');
/************************************ MySQL *************************************/
$connection = new \Nette\Database\Connection('mysql:host=localhost;dbname=njlogparser', 'nette', 'nette');
\Nette\Database\Helpers::loadFromFile($connection, __DIR__ . '/db.structure.mysql.sql');
if (!defined('STDIN')) {
    echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>' . '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Nette Jabber Log Parser</title></head><body><code><pre>';
}
$parser = new Parser($connection);
$parser->originalDataDir = __DIR__ . "/data";
//$parser->debug = TRUE;
$factory = new \Nette\Http\RequestFactory();
$factory->setEncoding('UTF-8');
$req = $factory->createHttpRequest();
if (($date = $req->getQuery('date', NULL)) || ($date = isset($argv[1]) ? $argv[1] : NULL)) {
    $parser->parseDate($date, TRUE);
} else {
    $parser->parse(10);
}
echo "\n\n";
$sec = $time = Debugger::timer();
$hours = (int) ($sec / 3600);
$sec -= $hours * 3600;
$mins = (int) ($sec / 60);
$sec -= $mins * 60;
$sec = (int) $sec;
echo "Total Time: " . round($time * 1000, 2) . "ms " . str_pad($hours, 2, 0, STR_PAD_LEFT) . ":" . str_pad($mins, 2, 0, STR_PAD_LEFT) . ":" . str_pad($sec, 2, 0, STR_PAD_LEFT) . "." . round(($time - $sec) * 1000) . "\n";
echo "Memory: " . round(memory_get_usage() / 1024, 2) . "KB (Real Memory: " . round(memory_get_usage(TRUE) / 1024, 2) . "KB)\n";
コード例 #7
0
ファイル: Stopwatch.php プロジェクト: venne/stopwatch-module
 public function stop($name, $key = NULL)
 {
     $this->add(Debugger::timer($key), $name);
 }
コード例 #8
0
ファイル: stopWatch.php プロジェクト: BroukPytlik/agility
 /**
  * Stop stopwatch
  * @author Pavel Železný <*****@*****.**>
  * @param string $name
  * @return string
  */
 public static function stop($name = NULL)
 {
     $time = \Nette\Diagnostics\Debugger::timer($name);
     self::$timers[$name !== NULL ? $name : uniqid()] = number_format(round($time * 1000, 1), 1);
     return $time;
 }
コード例 #9
0
 public function beforeRender()
 {
     \Nette\Diagnostics\Debugger::timer();
     // zapne stopky
     parent::beforeRender();
     //        dump($this->context->parameters);
     //        die();
     $this->template->pageLoadingMethod = $this->pageManagerService->getPageLoadingMode();
     //        // language detection
     //        if (!isset($this->lang)) {
     //            $this->lang = $this->getHttpRequest()->detectLanguage(array('cs', 'en'));
     //            $this->canonicalize();
     //        }
     //
     //        // lang priority: 1. from logged user, 2. from url, 3. default
     //        $this->lang = $this->template->lang =
     //                ($this->user->isLoggedIn() AND !empty($this->user->getIdentity()->lang)) ? $this->user->getIdentity()->lang : // is user logged? does he have "lang" defined? use it!
     //                $this->getParam("lang") ? : // is parametr "lang" set in url? use it!
     //                        $this->lang; // nothing above? use default
     //        // translator activation
     //
     //        // if "cs" is default, we don't need that in url
     //        if ($this->lang == "cs")
     //            $this->lang = NULL;
     //dump($this->lang ?: $this->langManagerService->getDefaultLanguage());
     //$this->context->translator->setLang($this->getFullLang());
     //$this->template->setTranslator($this->context->translator);
     $this->template->registerHelper('timeAgoInWords', 'Bubo\\Helpers\\Helpers::timeAgoInWords');
     // session example
     /*
      $this->namespace = $this->context->session->getSection($this->namespace);
      $this->namespace->setExpiration("+6 hours");
      $this->namespace->valueName = "valueContent";
     */
     $this->template->viewName = $this->view;
     //$this->template->root = dirname(realpath(APP_DIR));
     //$this->template->path = "/www";
     $a = strrpos($this->name, ':');
     if ($a === FALSE) {
         $this->template->moduleName = '';
         $this->template->presenterName = $this->name;
     } else {
         $this->template->moduleName = substr($this->name, 0, $a + 1);
         $this->template->presenterName = substr($this->name, $a + 1);
     }
     // synchrnonize acl
     //        $actualAcl = $this->context->resourceManager->getAcl();
     //        $this->getModelAcl()->synchronize($actualAcl);
 }