本文整理汇总了PHP中debug::timer方法的典型用法代码示例。如果您正苦于以下问题:PHP debug::timer方法的具体用法?PHP debug::timer怎么用?PHP debug::timer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类debug
的用法示例。
在下文中一共展示了debug::timer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: session_start
session_start();
// Checklist
require_once LIB . '/checklist.php';
// Instanciation des classes nécessaires au framework
new lang('fr');
new debug(QUERYTIMER);
/**
* Page manager
* @var page
*/
$page;
// Initialisation de la page
if (PAGE_LOADER) {
$page = new page();
}
// Implantation de tous les plugins
debug::timer('Loading plugins');
$dir = opendir(PLUGIN . '/');
while ($file = readdir($dir)) {
if ($file != "." && $file != "..") {
if (preg_match('#^function.([\\w]+).php$#', $file, $match)) {
// Simple fonction
if (!function_exists($match[1])) {
require_once PLUGIN . '/' . $file;
}
}
}
}
closedir($dir);
unset($dir);
register_shutdown_function("fatalError");
示例2: sql
/**
* Execute query and collect results
*
* @access public
* @param mixed $req SQL string to execute
* @return void
*/
public function sql($req)
{
// On vérifie que jusque là, tout se passe bien
if (DBHOST && !$this->error) {
try {
$queryStart = microtime(true);
if ($this->content['select']) {
// cache category - file prefix
$cachePref = $this->cache === true ? '' : md5('prefix' . $this->cache);
// Cache verification
if ($this->cache) {
// Already cached
$file = CACHE . '/sql/' . $cachePref . md5($req) . '.cache';
$this->cached = false;
// Cache exists and not too old
if (file_exists($file) && filemtime($file) > time() - SQLCACHETIME) {
$this->cached = true;
}
}
if (!$this->cached) {
$return = $this->bdd->query($req);
$return->setFetchMode(PDO::FETCH_ASSOC);
$results = $return->fetchAll();
// Must caching the request
if ($this->cache) {
$fileName = CACHE . '/sql/' . $cachePref . md5($req) . '.cache';
$file = fopen($fileName, 'w+');
fwrite($file, serialize($results));
fclose($file);
}
} else {
$results = unserialize(file_get_contents(CACHE . '/sql/' . $cachePref . md5($req) . '.cache'));
}
if ($this->cache) {
$this->cacheHash = $cachePref . md5($req);
}
// On compte le nombre d'occurence trouvée
$this->count = count($results);
// On enregistre les résultats
$this->results = $results;
} else {
// On récupère le nombre d'occurence touchée par la requête
$return = $this->bdd->exec($req);
$this->count = $return;
}
$queryEnd = microtime(true);
if (!$this->cached && debug::$timeQueries) {
// send data to timer
$nb = self::$queryNumber;
$a = '<a href="#debugQuery' . $nb . '" onclick="$(\'#debugSQLContent\').show();">';
debug::timer($a . 'Query ' . $nb . '</a>', true);
}
debug::sql($req, $this->count, $this->cached, $this->cache, $queryEnd - $queryStart);
return true;
} catch (Exception $error) {
debug::error("SQL", $error->getMessage() . "<br />" . $req, __FILE__, __LINE__);
$this->error = true;
return false;
}
} else {
return false;
}
}
示例3: debugger
/**
* Get the HTML for the debugger, and add the CSS and JS to the response
*
* @param array $elts
* @return string
*/
public static function debugger(array $elts = null)
{
if (is_null($elts)) {
debug::timer('nyro');
debug::timer('nyroRender');
return debug::debugger(array('timing' => array('Timing', debug::timer(), 'time'), 'included' => array('Included Files', get_included_files(), array('name' => 'code_red', 'type' => 'script')), 'session' => array('Session vars', $_SESSION, 'shield'), 'db_queries' => array('DB Queries', db::log(), 'database'), 'consts' => array('Constants', array_reverse(get_defined_constants(true), true), array('name' => 'gear', 'type' => 'script')), 'request' => array('Request', request::get(), array('name' => 'right', 'type' => 'arrow')), 'cookies' => array('Cookies', $_COOKIE, array('name' => 'gray', 'type' => 'user')), 'get' => array('Get', $_GET, array('name' => 'show', 'type' => 'tag')), 'post' => array('Post', $_POST, array('name' => 'green', 'type' => 'tag')), 'files' => array('Files', $_FILES, array('name' => 'orange', 'type' => 'tag')), 'response' => array('Response', array('Headers' => response::getInstance()->getHeader(), 'Included Files' => response::getInstance()->getIncFiles()), array('name' => 'right', 'type' => 'arrow'))));
}
if (request::get('out') != 'html') {
return;
}
$menu = array();
$content = array();
$close = utils::getIcon(array('name' => 'cross', 'type' => 'default', 'attr' => array('class' => 'close', 'alt' => 'Close')));
foreach ($elts as $k => $v) {
$icon = array_key_exists(2, $v) ? utils::getIcon(is_array($v[2]) ? $v[2] : array('name' => 'show', 'type' => $v[2])) : null;
$menu[] = '<a rel="' . $k . '">' . $icon . $v[0] . '</a>';
$tmp = '<div class="debugElt" id="' . $k . '" style="display: none;">' . $close . '<h2>' . $icon . $v[0] . '</h2>';
if (is_array($v[1])) {
if (is_numeric(key($v[1])) && !is_array($v[1])) {
$tmp .= '<ol><li>' . implode('</li><li>', $v[1]) . '</li></ol>';
} else {
$tmp .= debug::trace($v[1]);
}
} else {
$tmp .= $v[1];
}
$tmp .= '</div>';
$content[] = $tmp;
}
$resp = response::getInstance();
return '<div id="nyroDebugger">' . $resp->getIncludeTagFile('js', 'debug') . $resp->getIncludeTagFile('css', 'debug') . '<ul><li id="close">' . $close . '</li><li>' . implode('</li><li>', $menu) . '</li></ul>' . implode("\n", $content) . '</div>';
}
示例4: analyse
protected function analyse() {
$this->isSource = TRUE;
// collect informations from all classes
foreach(array_merge(array($this->sourceDir), $this->libDirs) as $dir) {
foreach(Finder::findFiles("*.php")->from($dir)->exclude($this->ignoredDirs) as $fileInfo) {
debug::timer($fileInfo->getFilename());
$this->parseFile($fileInfo->getPath() . "/" . $fileInfo->getFilename());
$this->onOutput(self::OI_FILE_ANALYSED, array(
self::FILE => $fileInfo->getFilename(),
self::TIME => debug::timer($fileInfo->getFilename()),
));
}
$this->isSource = FALSE;
}
}
示例5: main
/**
* Website main
*/
public static function main() {
define('NYROVERSION', '0.2');
$globalContent = null;
$globalVars = null;
$cacheInst = null;
$cacheInstVars = null;
try {
self::init();
$resp = response::getInstance();
self::$cfg->overload(__CLASS__.'Response');
if (self::$cfg->globalCache && !request::isPost() && count($_GET) == 0 && $resp->canGlobalCache()) {
$prm = is_array(self::$cfg->globalCache) ? self::$cfg->globalCache : array();
$cacheInst = cache::getInstance(array_merge(array('serialize'=>false), $prm));
$id = str_replace('/', '._.', '/'.request::get('request')).(request::isAjax() ? '-ajax' : '');
$cacheInst->get($globalContent, array(
'id'=>$id
));
$cacheInstVars = cache::getInstance(array_merge(array('serialize'=>true), $prm));
$cacheInstVars->get($globalVars, array(
'id'=>$id.'-vars'
));
}
if (is_null($globalContent)) {
request::execModule();
if (DEV) {
debug::timer('nyroProcess');
debug::timer('nyroRender');
}
$resp->setContent(request::publishModule());
}
} catch (module_exception $e) {
session::setFlash('nyroError', 'MODULE or ACTION NOT FOUND<br />'.self::handleError($e));
$resp->error(null, 404);
} catch (nException $e) {
session::setFlash('nyroError', self::handleError($e));
$resp->error(null, 500);
} catch (PDOException $e) {
session::setFlash('nyroError', self::handleError($e));
$resp->error(null, 500);
} catch (Exception $e) {
session::setFlash('nyroError', self::handleError($e));
$resp->error(null, 500);
}
try {
factory::saveCache();
if ($cacheInst) {
if ($globalContent) {
$resp->setVarsFromGlobalCache($globalVars);
echo $globalContent;
} else {
$globalVars = $resp->getVarsForGlobalCache();
$globalContent = $resp->send();
$cacheInst->save();
$cacheInstVars->save();
echo $globalContent;
}
} else {
echo $resp->send();
}
} catch (Exception $e) {
echo debug::trace($e);
}
}
示例6: define
<?php
define('PAGE_LOADER', true);
require_once '../config.php';
// Chargement des configurations
require_once LIB . '/init.php';
// Initialisation du Framework
// Inclusion par défaut des plugins
$session = new session();
// Plugin session
// Inclusion des fichiers statiques nécéssaires à SnakePHP
$page->pushCSS('snakephp/bootstrap');
$page->pushJS('snakephp/jquery');
$page->pushJS('snakephp/bootstrap');
// Inclusion des fichiers personnalisés
$page->pushCSS('global');
$page->pushJS('script');
// Initalisation du premier dispatcher
debug::timer('General dispatcher');
include $page->dispatcher("/");
// Assignation final au template
$page->template('page', $page);
$page->template('save', $_SESSION['save']);
$page->template('message', $_SESSION['message']);
// Génération du template
$page->display('template');
// Nettoyage des sessions et des variables
$page->clear();
exit;
示例7: display
/**
* Display page according to a template. Path is relative to /app/template/
* @param String $template[optional] path to template - default: template
* @return void
*/
public function display($template = false)
{
if (!$template) {
$template = $this->templateTPL;
}
$file = TEMPLATE . '/' . $template . ".tpl";
debug::timer('Loading template "' . $template . '.tpl"');
$template = new template($file);
foreach ($this->assign as $key => $value) {
$template->assign($key, $value);
}
$template->display(true);
}