本文整理汇总了PHP中Nette\Diagnostics\Debugger::timer方法的典型用法代码示例。如果您正苦于以下问题:PHP Debugger::timer方法的具体用法?PHP Debugger::timer怎么用?PHP Debugger::timer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Diagnostics\Debugger
的用法示例。
在下文中一共展示了Debugger::timer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stopQuery
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: stopQuery
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: shutdown
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: makeRequest
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: stop
public static function stop($name)
{
$time = Debugger::timer($name);
self::$timers[$name] = $time;
}
示例6: Parser
/*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: stop
public function stop($name, $key = NULL)
{
$this->add(Debugger::timer($key), $name);
}
示例8: stop
/**
* Stop stopwatch
* @author Pavel Železný <pavel.zezlenzy@socialbakers.com>
* @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: beforeRender
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);
}