本文整理汇总了PHP中JProfiler类的典型用法代码示例。如果您正苦于以下问题:PHP JProfiler类的具体用法?PHP JProfiler怎么用?PHP JProfiler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JProfiler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Execute the task
*
* @param array $taskData Task data
*
* @return bool True on success, false otherwise
*/
public function run($taskData)
{
$languages = NenoHelper::getLanguages();
$defaultLanguage = NenoSettings::get('source_language');
$profiler = new JProfiler();
foreach ($languages as $language) {
if ($language->lang_code !== $defaultLanguage) {
$profiler->mark('Before create job' . $language->lang_code . ' Method: Machine');
$machineJob = NenoJob::createJob($language->lang_code, NenoContentElementTranslation::MACHINE_TRANSLATION_METHOD);
$profiler->mark('After create job' . $language->lang_code . ' Method: Machine');
// If there are translations for this language and for this translation method
if ($machineJob !== null) {
NenoLog::add(count($machineJob->getTranslations()) . ' translations have been found to translate through machine translation');
}
$proJob = NenoJob::createJob($language->lang_code, NenoContentElementTranslation::PROFESSIONAL_TRANSLATION_METHOD);
// If there are translations for this language and for this translation method
if ($proJob !== null) {
NenoLog::add(count($proJob->getTranslations()) . ' translations have been found to translate through professional translation');
}
if ($machineJob !== null || $proJob !== null) {
NenoTaskMonitor::addTask('job_sender');
}
}
}
}
示例2: _doCheck
public static function _doCheck()
{
jimport('joomla.error.profiler');
// creating the profiler object will start the counter
$profiler = JProfiler::getInstance('sh404sef_analytics_profiler');
// if not set to auto check and not forced to do so
// when user click on "check updates" button
// we don't actually try to get updates info
$sefConfig =& Sh404sefFactory::getConfig();
// check if allowed to auto check, w/o user clicking on button
if (!$sefConfig->autoCheckNewAnalytics && !self::$_options['forced']) {
// prepare a default response object
$response = new stdClass();
$response->status = true;
$response->statusMessage = JText::_('COM_SH404SEF_CLICK_TO_CHECK_ANALYTICS');
$response->note = '';
return $response;
}
// calculate adapted class name
$className = 'Sh404sefAdapterAnalytics' . strtolower($sefConfig->analyticsType);
$handler = new $className();
// ask specialized class to fetch analytics data
$response = $handler->fetchAnalytics($sefConfig, self::$_options);
// done; send response back
return $response;
}
示例3: retrieve
/**
* Retrieve the storage content.
*
* @param string $lang E.g. de-DE, es-ES etc.
* @param string $extension E.g. joomla, com_weblinks, com_easycreator etc.
* @param string $domain Must be 'admin' or 'site'.
*
* @throws G11nException
* @return \g11n\Support\Store
*/
public function retrieve($lang, $extension, $domain = '')
{
if (self::$storage == 'off') {
return false;
}
$profiler = JProfiler::getInstance('LangDebug');
$profiler->mark('start: ' . $extension);
$this->query->clear('where');
$this->query->where('extension = ' . $this->db->quote($extension));
$this->query->where('lang = ' . $this->db->quote($lang));
$this->query->where('scope = ' . $this->db->quote($this->scope));
$this->db->setQuery($this->query);
$e = $this->db->loadObject();
if (empty($e->strings)) {
$profiler->mark('<span style="color: red;">langload db failed ****</span>' . $this->query);
$this->setError($this->db->getError());
return false;
}
$strings = json_decode($e->strings, true);
$profiler->mark('<span style="color: green;">*Loaded db*</span>');
$this->strings = array_merge($this->strings, $strings);
// Language overrides
$this->strings = array_merge($this->strings, $this->override);
$this->paths[$extension][$fileName] = true;
return true;
}
示例4: plgSh404sefAnalyticsCustomVars
function plgSh404sefAnalyticsCustomVars(&$customVars, $sefConfig)
{
// add custom variable : page creation time
if ($sefConfig->analyticsEnableTimeCollection) {
$profiler =& JProfiler::getInstance('sh404sef_profiler');
$profiler->mark('');
$pageCreationTime = $profiler->getBuffer();
//extract Data
$pageCreationTime = str_replace('sh404sef_profiler : ', '', $pageCreationTime[0]);
$tmp = explode(', ', $pageCreationTime);
// we may have memory report attached
$time = str_replace(' seconds', '', $tmp[0]);
// classify exact time into predefined categories for encoding
$time = Sh404sefHelperAnalytics::classifyTime($time);
// same for memory used
$memory = empty($tmp[1]) ? 0 : sh404sefHelperAnalytics::classifyMemory(str_replace(' MB', '', trim($tmp[1])));
// store results into incoming array
$customVars[SH404SEF_ANALYTICS_TIME_CUSTOM_VAR]->name = 'Page creation time and ram';
$customVars[SH404SEF_ANALYTICS_TIME_CUSTOM_VAR]->value = ($time << 4) + $memory;
}
// add custom variable : user logged in
if ($sefConfig->analyticsEnableUserCollection) {
$user = JFactory::getUser();
$customVars[SH404SEF_ANALYTICS_USER_CUSTOM_VAR]->name = 'Logged-in user';
$userType = empty($user->usertype) ? 'anonymous' : $user->usertype;
$customVars[SH404SEF_ANALYTICS_USER_CUSTOM_VAR]->value = htmlentities($userType, ENT_QUOTES, 'UTF-8');
}
return true;
}
示例5: templates
/**
* Display the template list.
*
* @return void
*/
private function templates()
{
$input = JFactory::getApplication()->input;
$profiling = false;
if ($profiling) {
// jimport('joomla.error.profiler');
$this->profiler = JProfiler::getInstance('EasyCreator');
}
$this->task = $input->get('task');
$this->ecr_project = $input->get('ecr_project');
$this->path = ECRPATH_EXTENSIONTEMPLATES;
$this->file_path = $input->getPath('file_path');
$this->file_name = $input->getPath('file_name');
$this->com_type = $input->get('com_type');
$this->template = $input->get('template');
$this->comTypes = EcrProjectHelper::getProjectTypes();
$cache = JFactory::getCache();
$cache->setCaching(1);
if ($profiling) {
$this->profiler->mark('start get templates');
}
$this->templates = EcrProjectTemplateHelper::getTemplateList();
if ($profiling) {
$this->profiler->mark('end get cached templates');
}
if ($profiling) {
echo '<pre>' . print_r($this->profiler->getBuffer(), true) . '</pre>';
}
$this->setLayout('templates');
}
示例6: __construct
public function __construct($context)
{
$this->context = $context;
if (JvrelInit::getCfg('debug')) {
$this->profiler = JProfiler::getInstance('Application');
}
$this->eopsob = new JvrelativesEopsob();
}
示例7: postflight
/**
* Called after any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install)
* @param jadapterinstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function postflight($route, JAdapterInstance $adapter)
{
if (JDEBUG) {
JProfiler::getInstance('Application')->mark('after' . ucfirst($route) . 'Projectfork');
$buffer = JProfiler::getInstance('Application')->getBuffer();
$app = JFactory::getApplication();
foreach ($buffer as $mark) {
$app->enqueueMessage($mark, 'debug');
}
}
return true;
}
示例8: __destruct
/**
* Adds application response time and memory usage to Chrome Inspector with ChromeLogger extension
*
* See: https://chrome.google.com/webstore/detail/chrome-logger/noaneddfkdjfnfdakjjmocngnfkfehhd
*/
public function __destruct()
{
if (JDEBUG && !headers_sent()) {
$buffer = JProfiler::getInstance('Application')->getBuffer();
if ($buffer) {
$data = strip_tags(end($buffer));
$row = array(array($data), null, 'info');
$header = array('version' => '4.1.0', 'columns' => array('log', 'backtrace', 'type'), 'rows' => array($row));
header('X-ChromeLogger-Data: ' . base64_encode(utf8_encode(json_encode($header))));
}
}
}
示例9: getApplication
/**
* Returns a Joomla application with a root user logged in
*
* @param string $base Base path for the Joomla installation
* @param int $client_id Application client id to spoof. Defaults to admin.
*
* @return Application
*/
public static function getApplication($base, $client_id = self::ADMIN)
{
$_SERVER['SERVER_PORT'] = 80;
if (!self::$_application) {
self::bootstrap($base);
$options = array('root_user' => 'root', 'client_id' => $client_id);
self::$_application = new Application($options);
$credentials = array('name' => 'root', 'username' => 'root', 'groups' => array(8), 'email' => 'root@localhost.home');
self::$_application->authenticate($credentials);
// If there are no marks in JProfiler debug plugin performs a division by zero using count($marks)
\JProfiler::getInstance('Application')->mark('Hello world');
}
return self::$_application;
}
示例10: store
/**
* Stores the strings into a storage.
*
* @param string $lang E.g. de-DE, es-ES etc.
* @param string $extension E.g. joomla, com_weblinks, com_easycreator etc.
* @param string $domain Must be 'admin' or 'site'.
*
* @throws G11nException
* @return boolean
*/
public function store($lang, $extension, $domain = '')
{
if (self::$storage == 'off') {
return false;
}
$profiler = JProfiler::getInstance('LangDebug');
$profiler->mark('store: ' . $extension);
// # $fileNames = JFolder::files(JPATH_ADMINISTRATOR, '.sys.ini', false, true);
$strings = self::parseFile($fileName);
$path = self::$cacheDir . '/' . $lang . '.' . $extension . '.txt';
$jsonString = json_encode($strings);
if (!JFile::write($path, $jsonString)) {
throw new G11nException('Unable to write language storage file');
}
$profiler->mark('<span style="color: blue;">wrote file</span>: ' . str_replace(JPATH_ROOT, 'J', $path));
$profiler->mark('store SUCCESS ++++: ' . $extension);
return true;
}
示例11: getApplication
/**
* Returns a Joomla application with a root user logged in
*
* @param string $base Base path for the Joomla installation
* @return Application
*/
public static function getApplication($base)
{
$_SERVER['SERVER_PORT'] = 80;
if (!defined('_JEXEC')) {
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['HTTP_USER_AGENT'] = 'joomla-cli/1.0.0';
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
define('JPATH_BASE', realpath($base));
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
require_once JPATH_LIBRARIES . '/import.php';
require_once JPATH_LIBRARIES . '/cms.php';
}
$credentials = array('name' => 'root', 'username' => 'root', 'groups' => array(8), 'email' => 'root@localhost.home');
$application = new Application(array('root_user' => 'root'));
$application->authenticate($credentials);
// If there are no marks in JProfiler debug plugin performs a division by zero using count($marks)
\JProfiler::getInstance('Application')->mark('Hello world');
return $application;
}
示例12: onAfterInitialise
/**
* Converting the site URL to fit to the HTTP request.
*
* @return void
*
* @since 1.5
*/
public function onAfterInitialise()
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
if ($app->isAdmin()) {
return;
}
if (count($app->getMessageQueue())) {
return;
}
if ($user->get('guest') && $app->input->getMethod() == 'GET') {
$this->_cache->setCaching(true);
}
$data = $this->_cache->get($this->_cache_key);
if ($data !== false) {
// Set cached body.
$app->setBody($data);
echo $app->toString();
if (JDEBUG) {
JProfiler::getInstance('Application')->mark('afterCache');
}
$app->close();
}
}
示例13: array
} else {
$_view = 'others';
}
$show_in_views = $params->get('show_in_views', array());
$show_in_views = !is_array($show_in_views) ? array($show_in_views) : $show_in_views;
$views_show_mod = !count($show_in_views) || in_array($_view, $show_in_views);
if ($params->get('enable_php_rule', 0)) {
$php_show_mod = eval($params->get('php_rule'));
$show_mod = $params->get('combine_show_rules', 'AND') == 'AND' ? $views_show_mod && $php_show_mod : $views_show_mod || $php_show_mod;
} else {
$show_mod = $views_show_mod;
}
if ($show_mod) {
global $modfc_jprof;
jimport('joomla.error.profiler');
$modfc_jprof = new JProfiler();
$modfc_jprof->mark('START: FLEXIcontent Filter-Search Module');
// load english language file for 'mod_flexifilter' module then override with current language file
JFactory::getLanguage()->load('mod_flexifilter', JPATH_SITE, 'en-GB', true);
JFactory::getLanguage()->load('mod_flexifilter', JPATH_SITE, null, true);
// initialize various variables
$document = JFactory::getDocument();
$caching = $app->getCfg('caching', 0);
// include the helper only once
require_once dirname(__FILE__) . DS . 'helper.php';
// Other parameters
$moduleclass_sfx = $params->get('moduleclass_sfx', '');
$layout = $params->get('layout', 'default');
$add_ccs = $params->get('add_ccs', 1);
$add_tooltips = $params->get('add_tooltips', 1);
$autosubmit = $params->get('filter_autosubmit', 0);
示例14: process
/**
* Process the form
* Inline edit save routed here (not in raw)
*
* @return null
*/
public function process()
{
$profiler = JProfiler::getInstance('Application');
JDEBUG ? $profiler->mark('controller process: start') : null;
$app = JFactory::getApplication();
$package = $app->getUserState('com_fabrik.package', 'fabrik');
$input = $app->input;
if ($input->get('format', '') == 'raw') {
error_reporting(error_reporting() ^ (E_WARNING | E_NOTICE));
}
$viewName = $input->get('view', 'form');
$view = $this->getView($viewName, JFactory::getDocument()->getType());
if ($model = $this->getModel('form', 'FabrikFEModel')) {
$view->setModel($model, true);
}
$model->setId($input->getInt('formid', 0));
$model->packageId = $input->getInt('packageId');
$this->isMambot = $input->get('isMambot', 0);
$form = $model->getForm();
$model->rowId = $input->get('rowid', '', 'string');
/**
* $$$ hugh - need this in plugin manager to be able to treat a "Copy" form submission
* as 'new' for purposes of running plugins. Rob's comment in model process() seems to
* indicate that origRowId was for this purposes, but it doesn't work, 'cos always has a value.
*/
if ($input->get('Copy', 'no') !== 'no') {
$model->copyingRow(true);
}
// Check for request forgeries
if ($model->spoofCheck()) {
JSession::checkToken() or die('Invalid Token');
}
JDEBUG ? $profiler->mark('controller process validate: start') : null;
if (!$model->validate()) {
$this->handleError($view, $model);
return;
}
JDEBUG ? $profiler->mark('controller process validate: end') : null;
// Reset errors as validate() now returns ok validations as empty arrays
$model->clearErrors();
try {
$model->process();
} catch (Exception $e) {
$model->errors['process_error'] = true;
JError::raiseWarning(500, $e->getMessage());
}
if ($input->getInt('elid', 0) !== 0) {
// Inline edit show the edited element - ignores validations for now
$inlineModel = $this->getModel('forminlineedit', 'FabrikFEModel');
$inlineModel->setFormModel($model);
echo $inlineModel->showResults();
return;
}
// Check if any plugin has created a new validation error
if ($model->hasErrors()) {
FabrikWorker::getPluginManager()->runPlugins('onError', $model);
$this->handleError($view, $model);
return;
}
/**
* If debug submit is requested (&fabrikdebug=2, and J! debug on, and Fabrik debug allowed),
* bypass any and all redirects, so we can see the profile for the submit
*/
if (FabrikHelperHTML::isDebugSubmit()) {
return;
}
$listModel = $model->getListModel();
$listModel->set('_table', null);
$url = $this->getRedirectURL($model);
$msg = $this->getRedirectMessage($model);
// @todo -should get handed off to the json view to do this
if ($input->getInt('fabrik_ajax') == 1) {
// $$$ hugh - adding some options for what to do with redirect when in content plugin
// Should probably do this elsewhere, but for now ...
$redirect_opts = array('msg' => $msg, 'url' => $url, 'baseRedirect' => $this->baseRedirect, 'rowid' => $input->get('rowid', '', 'string'), 'suppressMsg' => !$model->showSuccessMsg());
if (!$this->baseRedirect && $this->isMambot) {
$session = JFactory::getSession();
$context = $model->getRedirectContext();
$redirect_opts['redirect_how'] = $session->get($context . 'redirect_content_how', 'popup');
$redirect_opts['width'] = (int) $session->get($context . 'redirect_content_popup_width', '300');
$redirect_opts['height'] = (int) $session->get($context . 'redirect_content_popup_height', '300');
$redirect_opts['x_offset'] = (int) $session->get($context . 'redirect_content_popup_x_offset', '0');
$redirect_opts['y_offset'] = (int) $session->get($context . 'redirect_content_popup_y_offset', '0');
$redirect_opts['title'] = $session->get($context . 'redirect_content_popup_title', '');
$redirect_opts['reset_form'] = $session->get($context . 'redirect_content_reset_form', '1') == '1';
} elseif (!$this->baseRedirect && !$this->isMambot) {
/**
* $$$ hugh - I think this case only happens when we're a popup form from a list
* in which case I don't think "popup" is realy a valid option. Anyway, need to set something,
* so for now just do the same as we do for isMambot, but default redirect_how to 'samepage'
*/
$session = JFactory::getSession();
$context = $model->getRedirectContext();
$redirect_opts['redirect_how'] = $session->get($context . 'redirect_content_how', 'samepage');
//.........这里部分代码省略.........
示例15: displayQueries
//.........这里部分代码省略.........
$title = '<span class="dbg-noprofile">' . $title . '</span>';
}
$htmlProfile = $info[$id]->profile ? $info[$id]->profile : JText::_('PLG_DEBUG_NO_PROFILE');
// Backtrace and call stack.
$htmlCallStack = '';
if (isset($callStacks[$id])) {
$htmlCallStackElements = array();
foreach ($callStacks[$id] as $functionCall) {
if (isset($functionCall['file']) && isset($functionCall['line']) && strpos($functionCall['file'], '/libraries/joomla/database/') === false) {
$htmlFile = htmlspecialchars($functionCall['file']);
$htmlLine = htmlspecialchars($functionCall['line']);
$htmlCallStackElements[] = '<span class="dbg-log-called-from">' . $this->formatLink($htmlFile, $htmlLine) . '</span>';
}
}
$htmlCallStack = '<div class="dbg-query-table"><div>' . implode('</div><div>', $htmlCallStackElements) . '</div></div>';
if (!$this->linkFormat) {
$htmlCallStack .= '<div>[<a href="http://xdebug.org/docs/all_settings#file_link_format" target="_blank">';
$htmlCallStack .= JText::_('PLG_DEBUG_LINK_FORMAT') . '</a>]</div>';
}
}
$htmlAccordions = JHtml::_('bootstrap.startAccordion', 'dbg_query_' . $id, array('active' => $info[$id]->hasWarnings ? 'dbg_query_explain_' . $id : ''));
$htmlAccordions .= JHtml::_('bootstrap.addSlide', 'dbg_query_' . $id, JText::_('PLG_DEBUG_EXPLAIN'), 'dbg_query_explain_' . $id) . $info[$id]->explain . JHtml::_('bootstrap.endSlide');
$htmlAccordions .= JHtml::_('bootstrap.addSlide', 'dbg_query_' . $id, $title, 'dbg_query_profile_' . $id) . $htmlProfile . JHtml::_('bootstrap.endSlide');
if ($htmlCallStack) {
$htmlAccordions .= JHtml::_('bootstrap.addSlide', 'dbg_query_' . $id, JText::_('PLG_DEBUG_CALL_STACK'), 'dbg_query_callstack_' . $id) . $htmlCallStack . JHtml::_('bootstrap.endSlide');
}
$htmlAccordions .= JHtml::_('bootstrap.endAccordion');
$did = md5($query);
if (isset($duplicates[$did])) {
$dups = array();
foreach ($duplicates[$did] as $dup) {
if ($dup != $id) {
$dups[] = '<a href="#dbg-query-' . ($dup + 1) . '">#' . ($dup + 1) . '</a>';
}
}
$htmlQuery = '<div class="alert alert-error">' . JText::_('PLG_DEBUG_QUERY_DUPLICATES') . ': ' . implode(' ', $dups) . '</div>' . '<pre class="alert hasTooltip" title="' . JHtml::tooltipText('PLG_DEBUG_QUERY_DUPLICATES_FOUND') . '">' . $text . '</pre>';
} else {
$htmlQuery = '<pre>' . $text . '</pre>';
}
$list[] = '<a name="dbg-query-' . ($id + 1) . '"></a>' . $htmlTiming . $htmlBar . $htmlQuery . $htmlAccordions;
} else {
$list[] = '<pre>' . $text . '</pre>';
}
}
$totalTime = 0;
foreach (JProfiler::getInstance('Application')->getMarks() as $mark) {
$totalTime += $mark->time;
}
if ($totalQueryTime > $totalTime * 0.25) {
$labelClass = 'label-important';
} elseif ($totalQueryTime < $totalTime * 0.15) {
$labelClass = 'label-success';
} else {
$labelClass = 'label-warning';
}
if ($this->totalQueries == 0) {
$this->totalQueries = $db->getCount();
}
$html = array();
$html[] = '<h4>' . JText::sprintf('PLG_DEBUG_QUERIES_LOGGED', $this->totalQueries) . sprintf(' <span class="label ' . $labelClass . '">%.1f ms</span>', $totalQueryTime) . '</h4><br />';
if ($total_duplicates) {
$html[] = '<div class="alert alert-error">' . '<h4>' . JText::sprintf('PLG_DEBUG_QUERY_DUPLICATES_TOTAL_NUMBER', $total_duplicates) . '</h4>';
foreach ($duplicates as $dups) {
$links = array();
foreach ($dups as $dup) {
$links[] = '<a href="#dbg-query-' . ($dup + 1) . '">#' . ($dup + 1) . '</a>';
}
$html[] = '<div>' . JText::sprintf('PLG_DEBUG_QUERY_DUPLICATES_NUMBER', count($links)) . ': ' . implode(' ', $links) . '</div>';
}
$html[] = '</div>';
}
$html[] = '<ol><li>' . implode('<hr /></li><li>', $list) . '<hr /></li></ol>';
if (!$this->params->get('query_types', 1)) {
return implode('', $html);
}
// Get the totals for the query types.
$totalSelectQueryTypes = count($selectQueryTypeTicker);
$totalOtherQueryTypes = count($otherQueryTypeTicker);
$totalQueryTypes = $totalSelectQueryTypes + $totalOtherQueryTypes;
$html[] = '<h4>' . JText::sprintf('PLG_DEBUG_QUERY_TYPES_LOGGED', $totalQueryTypes) . '</h4>';
if ($totalSelectQueryTypes) {
$html[] = '<h5>' . JText::_('PLG_DEBUG_SELECT_QUERIES') . '</h5>';
arsort($selectQueryTypeTicker);
$list = array();
foreach ($selectQueryTypeTicker as $query => $occurrences) {
$list[] = '<pre>' . JText::sprintf('PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES', $this->highlightQuery($query), $occurrences) . '</pre>';
}
$html[] = '<ol><li>' . implode('</li><li>', $list) . '</li></ol>';
}
if ($totalOtherQueryTypes) {
$html[] = '<h5>' . JText::_('PLG_DEBUG_OTHER_QUERIES') . '</h5>';
arsort($otherQueryTypeTicker);
$list = array();
foreach ($otherQueryTypeTicker as $query => $occurrences) {
$list[] = '<pre>' . JText::sprintf('PLG_DEBUG_QUERY_TYPE_AND_OCCURRENCES', $this->highlightQuery($query), $occurrences) . '</pre>';
}
$html[] = '<ol><li>' . implode('</li><li>', $list) . '</li></ol>';
}
return implode('', $html);
}