本文整理汇总了PHP中xdebug_memory_usage函数的典型用法代码示例。如果您正苦于以下问题:PHP xdebug_memory_usage函数的具体用法?PHP xdebug_memory_usage怎么用?PHP xdebug_memory_usage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xdebug_memory_usage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: bench
public function bench(RestServer $rest)
{
$rest->getResponse()->appendResponse("It took " . round(xdebug_time_index(), 5) . " seconds\n");
$rest->getResponse()->appendResponse("Used " . round(xdebug_memory_usage() / 1024, 5) . "Kb of Memory\n");
$rest->getResponse()->appendResponse("Used at peak " . round(xdebug_peak_memory_usage() / 1024, 5) . "Kb of Memory\n");
return $rest;
}
开发者ID:nolazybits,项目名称:restserver,代码行数:7,代码来源:server.php
示例2: onApiRespond
/**
* @param \Civi\API\Event\RespondEvent $event
* API response event.
*/
public function onApiRespond(\Civi\API\Event\RespondEvent $event)
{
$apiRequest = $event->getApiRequest();
$result = $event->getResponse();
if (function_exists('xdebug_time_index') && \CRM_Utils_Array::value('debug', $apiRequest['params']) && is_array($result)) {
$result['xdebug']['peakMemory'] = xdebug_peak_memory_usage();
$result['xdebug']['memory'] = xdebug_memory_usage();
$result['xdebug']['timeIndex'] = xdebug_time_index();
$event->setResponse($result);
}
}
开发者ID:kidaa30,项目名称:yes,代码行数:15,代码来源:XDebugSubscriber.php
示例3: xdebugInfo
/**
* Weird little script to trigger an xdebug info box.
* I use this to test for bottlenecks before I discovered cache grind. I'll leave it in incase I need it for something.
*
* @param string $msg A message, useful for identifying a break point.
*/
function xdebugInfo ($msg = false)
{
if ($init['debug'])
{
trigger_error(
'[xdbInfo] ' . ($msg ? '<span style="color:white;background-color:#D60;">' . $msg . '</span> | ' : null) .
'
Mem: <span style="color:white;background-color:#D60;">' . Round(
(xdebug_memory_usage() / 1000), 2) . '
Kb</span>, Time: <span style="color:white;background-color:#D60;">' . str_pad(
Round(xdebug_time_index(), 4), 6, '0') . 'secs</span>', E_USER_WARNING);
}
}
开发者ID:radiosilence,项目名称:quickbox,代码行数:19,代码来源:errors.php
示例4: getMemoryUsage
/**
* Returns memory usage
*
* @return string
*/
public static function getMemoryUsage()
{
$memory = false;
if (function_exists('xdebug_memory_usage')) {
$memory = xdebug_memory_usage();
} elseif (function_exists('memory_get_usage')) {
$memory = memory_get_usage();
}
if ($memory === false) {
return "Memory usage function not found.";
}
$usage = number_format(round($memory / 1024 / 1024, 2), 2);
return "{$usage} Mb";
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:19,代码来源:Profiler.php
示例5: civicrm_api
/**
* @param string $entity
* type of entities to deal with
* @param string $action
* create, get, delete or some special action name.
* @param array $params
* array to be passed to function
* @param null $extra
*
* @return array|int
*/
function civicrm_api($entity, $action, $params, $extra = NULL)
{
$apiRequest = array();
$apiRequest['entity'] = CRM_Utils_String::munge($entity);
$apiRequest['action'] = CRM_Utils_String::munge($action);
$apiRequest['version'] = civicrm_get_api_version($params);
$apiRequest['params'] = $params;
$apiRequest['extra'] = $extra;
$apiWrappers = array(CRM_Utils_API_HTMLInputCoder::singleton(), CRM_Utils_API_NullOutputCoder::singleton(), CRM_Utils_API_ReloadOption::singleton(), CRM_Utils_API_MatchOption::singleton());
CRM_Utils_Hook::apiWrappers($apiWrappers, $apiRequest);
try {
require_once 'api/v3/utils.php';
require_once 'api/Exception.php';
if (!is_array($params)) {
throw new API_Exception('Input variable `params` is not an array', 2000);
}
_civicrm_api3_initialize();
$errorScope = CRM_Core_TemporaryErrorScope::useException();
// look up function, file, is_generic
$apiRequest += _civicrm_api_resolve($apiRequest);
if (strtolower($action) == 'create' || strtolower($action) == 'delete' || strtolower($action) == 'submit') {
$apiRequest['is_transactional'] = 1;
$transaction = new CRM_Core_Transaction();
}
// support multi-lingual requests
if ($language = CRM_Utils_Array::value('option.language', $params)) {
_civicrm_api_set_locale($language);
}
_civicrm_api3_api_check_permission($apiRequest['entity'], $apiRequest['action'], $apiRequest['params']);
$fields = _civicrm_api3_api_getfields($apiRequest);
// we do this before we
_civicrm_api3_swap_out_aliases($apiRequest, $fields);
if (strtolower($action) != 'getfields') {
if (empty($apiRequest['params']['id'])) {
$apiRequest['params'] = array_merge(_civicrm_api3_getdefaults($apiRequest, $fields), $apiRequest['params']);
}
//if 'id' is set then only 'version' will be checked but should still be checked for consistency
civicrm_api3_verify_mandatory($apiRequest['params'], NULL, _civicrm_api3_getrequired($apiRequest, $fields));
}
// For input filtering, process $apiWrappers in forward order
foreach ($apiWrappers as $apiWrapper) {
$apiRequest = $apiWrapper->fromApiInput($apiRequest);
}
$function = $apiRequest['function'];
if ($apiRequest['function'] && $apiRequest['is_generic']) {
// Unlike normal API implementations, generic implementations require explicit
// knowledge of the entity and action (as well as $params). Bundle up these bits
// into a convenient data structure.
$result = $function($apiRequest);
} elseif ($apiRequest['function'] && !$apiRequest['is_generic']) {
_civicrm_api3_validate_fields($apiRequest['entity'], $apiRequest['action'], $apiRequest['params'], $fields);
$result = isset($extra) ? $function($apiRequest['params'], $extra) : $function($apiRequest['params']);
} else {
return civicrm_api3_create_error("API (" . $apiRequest['entity'] . ", " . $apiRequest['action'] . ") does not exist (join the API team and implement it!)");
}
// For output filtering, process $apiWrappers in reverse order
foreach (array_reverse($apiWrappers) as $apiWrapper) {
$result = $apiWrapper->toApiOutput($apiRequest, $result);
}
if (CRM_Utils_Array::value('format.is_success', $apiRequest['params']) == 1) {
if ($result['is_error'] === 0) {
return 1;
} else {
return 0;
}
}
if (!empty($apiRequest['params']['format.only_id']) && isset($result['id'])) {
return $result['id'];
}
if (CRM_Utils_Array::value('is_error', $result, 0) == 0) {
_civicrm_api_call_nested_api($apiRequest['params'], $result, $apiRequest['action'], $apiRequest['entity'], $apiRequest['version']);
}
if (function_exists('xdebug_time_index') && CRM_Utils_Array::value('debug', $apiRequest['params']) && is_array($result)) {
$result['xdebug']['peakMemory'] = xdebug_peak_memory_usage();
$result['xdebug']['memory'] = xdebug_memory_usage();
$result['xdebug']['timeIndex'] = xdebug_time_index();
}
return $result;
} catch (PEAR_Exception $e) {
if (CRM_Utils_Array::value('format.is_success', $apiRequest['params']) == 1) {
return 0;
}
$error = $e->getCause();
if ($error instanceof DB_Error) {
$data["error_code"] = DB::errorMessage($error->getCode());
$data["sql"] = $error->getDebugInfo();
}
if (!empty($apiRequest['params']['debug'])) {
if (method_exists($e, 'getUserInfo')) {
//.........这里部分代码省略.........
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:101,代码来源:api.php
示例6: getRecord
public function getRecord()
{
// record_files = array();
$lineNum = 0;
if (file_exists($this->_coverageLog)) {
if ($handle = fopen($this->_coverageLog, 'r')) {
$lineNumTotal = trim(shell_exec('cat ' . $this->_coverageLog . ' |wc -l'));
while (!feof($handle)) {
if ($line = fgets($handle)) {
$lineNum++;
echo "INFO____: Calculate line " . $lineNum . " (" . $lineNum . "/" . $lineNumTotal . ").\n";
echo "INFO____: Memory used: " . (int) (xdebug_memory_usage() / (1024 * 1024)) . "M.\n";
$record = json_decode($line, true);
$this->appendRecord($record);
// record_files_tmp = array_keys($record);
// record_files =
// array_unique(array_merge($record_files,
// $record_files_tmp));
}
}
unset($record);
fclose($handle);
return true;
} else {
throw new Exception("ERROR____: Read Record failed!");
}
}
throw new Exception("ERROR____: Record not exist!");
}
开发者ID:babymark,项目名称:PHPCoverage,代码行数:29,代码来源:PHPCoverageCalculator.php
示例7: log
private function log($level, $message)
{
//return;
//error_log("hello buddy in log()");
global $cfg;
if (!$this->enabled) {
return;
}
if (function_exists("xdebug_is_enabled") && xdebug_is_enabled()) {
//print "$level: $message";
//print_r(debug_backtrace(), true);
//using the xdebug version is failing with Canary Mismatch error
///$stack = xdebug_get_function_stack();
$stack = debug_backtrace();
$time = xdebug_time_index();
$mem = xdebug_memory_usage();
$entry = new LogEntry($level, $message, $stack, $time, $mem);
//error_log("finally here?");
} else {
$bt = debug_backtrace();
//print_r($bt);
// get class, function called by caller of caller of caller
$cl_f_msg = "";
if (isset($bt[2])) {
$class = isset($bt[2]['class']) ? $bt[2]['class'] : "";
$function = isset($bt[2]['function']) ? $bt[2]['function'] : "";
$cl_f_msg = ":{$class}::{$function}";
}
// get file, line where call to caller of caller was made
$file = $bt[1]['file'];
$file = str_replace($_SERVER['DOCUMENT_ROOT'], '', $file);
$line = $bt[1]['line'];
// build & return the message
$back_trace = "{$file}:{$cl_f_msg}:{$line} ";
$entry = new LogEntry($level, $message, $back_trace, 0, 0);
}
if ($cfg['servertype'] != 'prod') {
array_push($this->entries, $entry);
}
}
开发者ID:rajnishp,项目名称:bjs,代码行数:40,代码来源:ShopbookLogger.php
示例8: printMemoryUsage
public static function printMemoryUsage($prefixString = null)
{
$memory = false;
if (function_exists('xdebug_memory_usage')) {
$memory = xdebug_memory_usage();
} elseif (function_exists('memory_get_usage')) {
$memory = memory_get_usage();
}
if ($memory !== false) {
$usage = round($memory / 1024 / 1024, 2);
if (!is_null($prefixString)) {
Piwik::log($prefixString);
}
Piwik::log("Memory usage = {$usage} Mb");
} else {
Piwik::log("Memory usage function not found.");
}
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:18,代码来源:Piwik.php
示例9: printCommonFooter
/**
* Print common footer :
* conf->global->MAIN_HTML_FOOTER
* conf->global->MAIN_GOOGLE_AN_ID
* conf->global->MAIN_SHOW_TUNING_INFO or $_SERVER["MAIN_SHOW_TUNING_INFO"]
* conf->logbuffer
*
* @param string $zone 'private' (for private pages) or 'public' (for public pages)
* @return void
*/
function printCommonFooter($zone = 'private')
{
global $conf, $hookmanager;
global $micro_start_time;
if ($zone == 'private') {
print "\n" . '<!-- Common footer for private page -->' . "\n";
} else {
print "\n" . '<!-- Common footer for public page -->' . "\n";
}
if (!empty($conf->global->MAIN_HTML_FOOTER)) {
print $conf->global->MAIN_HTML_FOOTER . "\n";
}
print "\n";
if (!empty($conf->use_javascript_ajax)) {
print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() {' . "\n";
print '<!-- If page_y set, we set scollbar with it -->' . "\n";
print "page_y=getParameterByName('page_y', 0);";
print "if (page_y > 0) \$('html, body').scrollTop(page_y);";
print '<!-- Set handler to add page_y param on some a href links -->' . "\n";
print 'jQuery(".reposition").click(function() {
var page_y = $(document).scrollTop();
/* alert(page_y); */
this.href=this.href+\'&page_y=\'+page_y;
});' . "\n";
print '});' . "\n";
print '</script>' . "\n";
}
// Google Analytics (need Google module)
if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) {
if (empty($conf->dol_use_jmobile)) {
print "\n";
print '<script type="text/javascript">' . "\n";
print ' var _gaq = _gaq || [];' . "\n";
print ' _gaq.push([\'_setAccount\', \'' . $conf->global->MAIN_GOOGLE_AN_ID . '\']);' . "\n";
print ' _gaq.push([\'_trackPageview\']);' . "\n";
print '' . "\n";
print ' (function() {' . "\n";
print ' var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;' . "\n";
print ' ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';' . "\n";
print ' var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);' . "\n";
print ' })();' . "\n";
print '</script>' . "\n";
}
}
// End of tuning
if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || !empty($conf->global->MAIN_SHOW_TUNING_INFO)) {
print "\n" . '<script type="text/javascript">' . "\n";
print 'window.console && console.log("';
if (!empty($conf->global->MEMCACHED_SERVER)) {
print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - ';
}
print 'MAIN_OPTIMIZE_SPEED=' . (isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off');
if ($micro_start_time) {
$micro_end_time = microtime(true);
print ' - Build time: ' . ceil(1000 * ($micro_end_time - $micro_start_time)) . ' ms';
}
if (function_exists("memory_get_usage")) {
print ' - Mem: ' . memory_get_usage();
}
if (function_exists("xdebug_memory_usage")) {
print ' - XDebug time: ' . ceil(1000 * xdebug_time_index()) . ' ms';
print ' - XDebug mem: ' . xdebug_memory_usage();
print ' - XDebug mem peak: ' . xdebug_peak_memory_usage();
}
if (function_exists("zend_loader_file_encoded")) {
print ' - Zend encoded file: ' . (zend_loader_file_encoded() ? 'yes' : 'no');
}
print '");' . "\n";
print '</script>' . "\n";
// Add Xdebug coverage of code
if (defined('XDEBUGCOVERAGE')) {
print_r(xdebug_get_code_coverage());
}
}
// If there is some logs in buffer to show
if (count($conf->logbuffer)) {
print "\n";
print "<!-- Start of log output\n";
//print '<div class="hidden">'."\n";
foreach ($conf->logbuffer as $logline) {
print $logline . "<br>\n";
}
//print '</div>'."\n";
print "End of log output -->\n";
}
$parameters = array();
$reshook = $hookmanager->executeHooks('printCommonFooter', $parameters);
// Note that $action and $object may have been modified by some hooks
}
开发者ID:NoisyBoy86,项目名称:Dolibarr_test,代码行数:99,代码来源:functions.lib.php
示例10: printCommonFooter
/**
* Print common footer :
* conf->global->MAIN_HTML_FOOTER
* conf->global->MAIN_GOOGLE_AN_ID
* DOL_TUNING
* conf->logbuffer
*
* @param string $zone 'private' (for private pages) or 'public' (for public pages)
* @return void
*/
function printCommonFooter($zone = 'private')
{
global $conf;
global $micro_start_time;
if ($zone == 'private') {
print "\n" . '<!-- Common footer for private page -->' . "\n";
} else {
print "\n" . '<!-- Common footer for public page -->' . "\n";
}
if (!empty($conf->global->MAIN_HTML_FOOTER)) {
print $conf->global->MAIN_HTML_FOOTER . "\n";
}
// Google Analytics (need Google module)
if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) {
if (empty($conf->dol_use_jmobile)) {
print "\n";
print '<script type="text/javascript">' . "\n";
print ' var _gaq = _gaq || [];' . "\n";
print ' _gaq.push([\'_setAccount\', \'' . $conf->global->MAIN_GOOGLE_AN_ID . '\']);' . "\n";
print ' _gaq.push([\'_trackPageview\']);' . "\n";
print '' . "\n";
print ' (function() {' . "\n";
print ' var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;' . "\n";
print ' ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';' . "\n";
print ' var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);' . "\n";
print ' })();' . "\n";
print '</script>' . "\n";
}
}
// End of tuning
if (!empty($_SERVER['DOL_TUNING']) || !empty($conf->global->MAIN_SHOW_TUNING_INFO)) {
print "\n" . '<script type="text/javascript">' . "\n";
print 'window.console && console.log("';
if (!empty($conf->global->MEMCACHED_SERVER)) {
print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - ';
}
print 'MAIN_OPTIMIZE_SPEED=' . (isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off');
if ($micro_start_time) {
$micro_end_time = dol_microtime_float(true);
print ' - Build time: ' . ceil(1000 * ($micro_end_time - $micro_start_time)) . ' ms';
}
if (function_exists("memory_get_usage")) {
print ' - Mem: ' . memory_get_usage();
}
if (function_exists("xdebug_memory_usage")) {
print ' - XDebug time: ' . ceil(1000 * xdebug_time_index()) . ' ms';
print ' - XDebug mem: ' . xdebug_memory_usage();
print ' - XDebug mem peak: ' . xdebug_peak_memory_usage();
}
if (function_exists("zend_loader_file_encoded")) {
print ' - Zend encoded file: ' . (zend_loader_file_encoded() ? 'yes' : 'no');
}
print '");' . "\n";
print '</script>' . "\n";
// Add Xdebug coverage of code
if (defined('XDEBUGCOVERAGE')) {
var_dump(xdebug_get_code_coverage());
}
}
// If there is some logs in buffer to show
if (count($conf->logbuffer)) {
print "\n";
print "<!-- Start of log output\n";
//print '<div class="hidden">'."\n";
foreach ($conf->logbuffer as $logline) {
print $logline . "<br>\n";
}
//print '</div>'."\n";
print "End of log output -->\n";
}
}
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:81,代码来源:functions.lib.php
示例11: setData
/**
* Détermine les données de la debug bar.
*
* @return void
*/
public function setData()
{
$this->aDebugBarData = array();
$this->aDebugBarData['num_data'] = array();
if ($this->aConfig['tabs']['super_globales']) {
$this->aDebugBarData['num_data']['get'] = count($_GET);
$this->aDebugBarData['num_data']['post'] = count($_POST);
$this->aDebugBarData['num_data']['cookie'] = count($_COOKIE);
$this->aDebugBarData['num_data']['files'] = count($_FILES);
$this->aDebugBarData['num_data']['session'] = count($_SESSION);
$this->aDebugBarData['num_data']['server'] = count($_SERVER);
$this->aDebugBarData['num_data']['env'] = count($_ENV);
$this->aDebugBarData['num_data']['request'] = count($_REQUEST);
}
if ($this->aConfig['tabs']['app']) {
$this->aDebugBarData['definedVars'] = self::getDefinedVars();
$this->aDebugBarData['definedConstants'] = self::getDefinedConstants();
$this->aDebugBarData['configVars'] = $this->okt->config->get();
$this->aDebugBarData['userVars'] = $this->okt->user->getData(0);
$this->aDebugBarData['l10nVars'] = !empty($__l10n) ? $__l10n : array();
$this->aDebugBarData['num_data']['definedVars'] = count($this->aDebugBarData['definedVars']);
$this->aDebugBarData['num_data']['definedConstants'] = count($this->aDebugBarData['definedConstants']);
$this->aDebugBarData['num_data']['configVars'] = count($this->aDebugBarData['configVars']);
$this->aDebugBarData['num_data']['userVars'] = count($this->aDebugBarData['userVars']);
$this->aDebugBarData['num_data']['l10nVars'] = count($this->aDebugBarData['l10nVars']);
}
if ($this->aConfig['tabs']['logs']) {
$this->aDebugBarData['num_data']['logs'] = $this->okt->debug->getNum();
}
if ($this->aConfig['tabs']['db']) {
$this->aDebugBarData['num_data']['queries'] = $this->okt->db->nbQueries();
}
if ($this->aConfig['tabs']['tools']) {
$this->aDebugBarData['execTime'] = util::getExecutionTime();
if (OKT_XDEBUG) {
$this->aDebugBarData['memUsage'] = util::l10nFileSize(xdebug_memory_usage());
$this->aDebugBarData['peakUsage'] = util::l10nFileSize(xdebug_peak_memory_usage());
} else {
$this->aDebugBarData['memUsage'] = util::l10nFileSize(memory_get_usage());
$this->aDebugBarData['peakUsage'] = util::l10nFileSize(memory_get_peak_usage());
}
}
}
开发者ID:jewelhuq,项目名称:okatea,代码行数:48,代码来源:class.oktDebugBar.php
示例12: output
/**
* Prepare template for render from View
*
* @throws \Exception if template path is incorrect
*/
public function output()
{
$template = $this->template;
$data = $this->data;
$css = $this->css;
$js = $this->js;
$title = $this->title;
ob_start();
try {
if (!file_exists(APP . "Templates/_pages/{$template}.html")) {
throw new \Exception("The required Template ({$template}) not exist.");
}
require APP . 'Templates/_shared/header.html';
require APP . "Templates/_pages/{$template}.html";
require APP . 'Templates/_shared/footer.html';
} catch (\Exception $e) {
echo 'Template exception: ', $e->getMessage(), "\n";
}
//only for debug, return time execution and memory usage
echo '<!-- Memory: ';
echo round(xdebug_memory_usage() / 1024, 2), ' (';
echo round(xdebug_peak_memory_usage() / 1024, 2), ') KByte - Time: ';
echo xdebug_time_index();
echo ' Seconds -->';
ob_end_flush();
}
开发者ID:s3b4stian,项目名称:app,代码行数:31,代码来源:HtmlTemplate.php
示例13: p2_print_memory_usage
/**
* メモリの使用量を表示する
*
* @return void
*/
function p2_print_memory_usage()
{
if (function_exists('memory_get_usage')) {
$usage = memory_get_usage();
} elseif (function_exists('xdebug_memory_usage')) {
$usage = xdebug_memory_usage();
} else {
$usage = -1;
}
$kb = $usage / 1024;
$kb = number_format($kb, 2, '.', '');
echo 'Memory Usage: ' . $kb . 'KiB';
}
开发者ID:xingskycn,项目名称:p2-php,代码行数:18,代码来源:global.funcs.php
示例14: xdebug_profiler_shutdown_cb
function xdebug_profiler_shutdown_cb()
{
$is_xmlhttprequest = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
if (isset($_REQUEST['XDEBUG_PROFILE'])) {
$used_memory = xdebug_memory_usage();
$sizename = array(" Bytes", " KB", " MB", " GB");
$used_memory = round($used_memory / pow(1024, $i = floor(log($used_memory, 1024))), 2) . $sizename[$i];
$elapsed_time = round(xdebug_time_index() * 1000, 3);
$profile = xdebug_get_profiler_filename();
$profile_id = md5($profile);
/* Show result box */
if (!$is_xmlhttprequest) {
if ($profile === false) {
$path = ini_get('xdebug.profiler_output_dir');
if ($path != '') {
$reason = is_dir($path) ? 'Directory is not writeable' : (file_exists($path) ? "'{$path}' is not directory" : "'{$path}' does not exist");
$output = sprintf('Error: Could not create profile dump in %s<br />(Reason: %s)', $path, $reason);
} else {
$output = 'Error: xdebug.profiler_output_dir is not set';
}
} else {
$output = "\n<b>Page generated in</b> {$elapsed_time} ms <b>Used memory:</b> {$used_memory}\n<b>Profiler dump:</b> <a href='/download.php?file={$profile}'>{$profile}</a>\n";
if ($_REQUEST['XDEBUG_PROFILE'] == 'long') {
$output .= shell_exec("/usr/bin/callgrind_annotate --inclusive=yes --tree=both {$profile}");
}
}
echo <<<DATA
<div style="position: absolute; top: 0; z-index: 5000; border: dashed black 1px; background-color: #fff;" id="xdebug_profile_{$profile_id}">
<a href="#" style="font-size: 11px;" onclick="javascript: document.getElementById('xdebug_profile_{$profile_id}').style.display = 'none'; return false;">[close]</a>
<pre style="padding: 5px;">{$output}</pre>
<a href="#" style="font-size: 11px;" onclick="javascript: document.getElementById('xdebug_profile_{$profile_id}').style.display = 'none'; return false;">[close]</a>
</div>
DATA;
}
}
/* Output box with toggles to enable/disable profiler and annotation */
if (!$is_xmlhttprequest) {
$profiler = isset($_REQUEST['XDEBUG_PROFILE']) ? array('enabled' => 1, 'checked' => 'checked="checked"', 'display' => 'inline') : array('enabled' => 0, 'checked' => '', 'display' => 'none');
$profiler['checked_annotate'] = isset($_REQUEST['XDEBUG_PROFILE']) && $_REQUEST['XDEBUG_PROFILE'] == 'long' ? 'checked="checked"' : '';
echo <<<DATA
<!-- XDEBUG Dynamic Profiler -->
<script type="text/javascript">
<!--
var xdebug_Profiler = {$profiler['enabled']};
function xdebug_setCookie(value)
{
if (value == '')
document.cookie = "XDEBUG_PROFILE=; path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT";
else
document.cookie = "XDEBUG_PROFILE=" + value + "; path=/; expires=Fri, 01-Jan-2038 00:00:01 GMT";
}
function xdebug_toggleProfiler(output)
{
var annotate = document.getElementById('xdebug_profiler_annotate');
if (xdebug_Profiler) {
xdebug_setCookie('');
xdebug_Profiler = 0;
annotate.style.display = 'none';
} else {
xdebug_setCookie(output);
xdebug_Profiler = 1;
annotate.style.display = 'inline';
}
return xdebug_Profiler;
}
// -->
</script>
<div style="padding: 5px; border: dashed black 1px; background-color: #fff; z-index: 1000; position: absolute; top: 0px; right: 5px; " id="xdebug_profile_enable_cookie">
<label for="xdebug_toggler" style="vertical-align: top">Toggle Profiler</label>
<input id="xdebug_toggler" type="checkbox" onclick="this.checked = xdebug_toggleProfiler(this.value);" value="short" {$profiler['checked']} />
<div id="xdebug_profiler_annotate" style="display: {$profiler['display']}">
<label for="xdebug_annotate" style="vertical-align: top">Annotate</label>
<input id="xdebug_annotate" type="checkbox" onclick="xdebug_setCookie((this.checked)?this.value:'short');" value="long" {$profiler['checked_annotate']} />
</div>
</div>
DATA;
}
}
开发者ID:bperel,项目名称:xdebug,代码行数:79,代码来源:online_profiling_prepend.php
示例15: error_reporting
<pre>
<?php
require 'ezc_mail_setup.php';
error_reporting(E_ALL);
$parser = new ezcMailParser();
$set = new ezcMailFileSet(array(dirname(__FILE__) . '/ezcmailtest.mail'));
echo "Memory: ", xdebug_memory_usage(), " bytes\n\n";
$mail = $parser->parseMail($set);
foreach ($mail as $mailPart) {
echo "From: {$mailPart->from->email}\n";
echo "Subject: {$mailPart->subject}\n";
}
unset($mail);
echo "\nMaximum Memory: ", xdebug_peak_memory_usage(), " bytes\n";
开发者ID:SandyS1,项目名称:presentations,代码行数:14,代码来源:dr_mail_test.php
示例16: llxFooter
function llxFooter($foot = '')
{
global $conf, $langs, $dolibarr_auto_user, $micro_start_time;
// Core error message
if (defined("MAIN_CORE_ERROR") && constant("MAIN_CORE_ERROR") == 1) {
// Ajax version
if ($conf->use_javascript_ajax) {
$title = img_warning() . ' ' . $langs->trans('CoreErrorTitle');
print ajax_dialog($title, $langs->trans('CoreErrorMessage'));
} else {
$msg = img_warning() . ' ' . $langs->trans('CoreErrorMessage');
print '<div class="error">' . $msg . '</div>';
}
define("MAIN_CORE_ERROR", 0);
}
print "\n\n";
if (preg_match('/^smartphone/', $conf->smart_menu) && isset($conf->browser->phone)) {
print '</div> <!-- end div data-role="content" -->' . "\n";
print '</div> <!-- end div data-role="page" -->' . "\n";
}
print '</div> <!-- end div class="fiche" -->' . "\n";
print "\n" . '</td></tr></table> <!-- end right area -->' . "\n";
if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) {
print '</div></div> <!-- end main layout -->' . "\n";
}
print "\n";
if ($foot) {
print '<!-- ' . $foot . ' -->' . "\n";
}
if (!empty($conf->global->MAIN_HTML_FOOTER)) {
print $conf->global->MAIN_HTML_FOOTER . "\n";
}
// If there is some logs in buffer to show
if (sizeof($conf->logbuffer)) {
print "\n";
print "<!-- Start of log output\n";
//print '<div class="hidden">'."\n";
foreach ($conf->logbuffer as $logline) {
print $logline . "<br>\n";
}
//print '</div>'."\n";
print "End of log output -->\n";
}
// End of tuning
if (!empty($_SERVER['DOL_TUNING'])) {
$micro_end_time = dol_microtime_float(true);
print "\n" . '<script type="text/javascript">console.log("';
if (!empty($conf->global->MEMCACHED_SERVER)) {
print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - ';
}
print 'MAIN_OPTIMIZE_SPEED=' . (isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off');
print ' - Build time: ' . ceil(1000 * ($micro_end_time - $micro_start_time)) . ' ms';
if (function_exists("memory_get_usage")) {
print ' - Mem: ' . memory_get_usage();
}
if (function_exists("xdebug_memory_usage")) {
print ' - XDebug time: ' . ceil(1000 * xdebug_time_index()) . ' ms';
print ' - XDebug mem: ' . xdebug_memory_usage();
print ' - XDebug mem peak: ' . xdebug_peak_memory_usage();
}
if (function_exists("zend_loader_file_encoded")) {
print ' - Zend encoded file: ' . (zend_loader_file_encoded() ? 'yes' : 'no');
}
print '")</script>' . "\n";
// Add Xdebug coverage of code
if (defined('XDEBUGCOVERAGE')) {
var_dump(xdebug_get_code_coverage());
}
}
print "</body>\n";
print "</html>\n";
}
开发者ID:netors,项目名称:dolibarr,代码行数:72,代码来源:main.inc.php
示例17: log
/**
* Log a message
*
* @param string $message The message to be logged
* @param int $loglevel The log level
*/
function log($message, $loglevel = MIDCOM_LOG_DEBUG)
{
if (!$this->_enabled || $this->_loglevel < $loglevel) {
return;
}
$file = fopen($this->_filename, 'a+');
if (function_exists('xdebug_memory_usage')) {
static $lastmem = 0;
$curmem = xdebug_memory_usage();
$delta = $curmem - $lastmem;
$lastmem = $curmem;
$prefix = sprintf("%s (%012.9f, %9s, %7s):\t", date('M d Y H:i:s'), xdebug_time_index(), number_format($curmem, 0, ',', '.'), number_format($delta, 0, ',', '.'));
} else {
$prefix = date('M d Y H:i:s') . "\t";
}
if (array_key_exists($loglevel, $this->_loglevels)) {
$prefix .= '[' . $this->_loglevels[$loglevel] . '] ';
}
//find the proper caller
$bt = debug_backtrace(false);
$prefix .= $this->_get_caller($bt);
fputs($file, $prefix . trim($message) . "\n");
fclose($file);
if ($this->firephp && !_midcom_headers_sent()) {
try {
$log_method = $this->_loglevels[$loglevel];
if ($loglevel == MIDCOM_LOG_DEBUG) {
$log_method = 'log';
}
if ($loglevel == MIDCOM_LOG_CRIT) {
$log_method = 'error';
}
$this->firephp->{$log_method}($message);
} catch (Exception $e) {
// Ignore FirePHP errors for now
}
}
}
开发者ID:nemein,项目名称:openpsa,代码行数:44,代码来源:debug.php
示例18: ob_start
if (file_exists($settings_file)) {
include $settings_file;
}
$BaseTemplate->template_path = SKINS_PATH;
Template::Set('MODULE_NAV_INC', $NAVBAR);
Template::Set('MODULE_HEAD_INC', $HTMLHead);
ob_start();
MainController::RunAllActions();
$page_content = ob_get_clean();
$BaseTemplate->Set('title', MainController::$page_title . ' - ' . SITE_NAME);
$BaseTemplate->Set('page_title', MainController::$page_title . ' - ' . SITE_NAME);
if (file_exists(SKINS_PATH . '/layout.tpl')) {
$BaseTemplate->Set('page_htmlhead', Template::Get('core_htmlhead.tpl', true));
$BaseTemplate->Set('page_htmlreq', Template::Get('core_htmlreq.tpl', true));
$BaseTemplate->Set('page_content', $page_content);
$BaseTemplate->ShowTemplate('layout.tpl');
} else {
# It's a template sammich!
$BaseTemplate->ShowTemplate('header.tpl');
echo $page_content;
$BaseTemplate->ShowTemplate('footer.tpl');
}
# Force connection close
DB::close();
if (Config::Get('XDEBUG_BENCHMARK')) {
$run_time = xdebug_time_index();
$memory_end = xdebug_memory_usage();
echo 'TOTAL MEMORY: ' . ($memory_end - $memory_start) . '<br />';
echo 'PEAK: ' . xdebug_peak_memory_usage() . '<br />';
echo 'RUN TIME: ' . $run_time . '<br />';
}
开发者ID:deanstalker,项目名称:phpVMS,代码行数:31,代码来源:index.php
示例19: xMemory
static function xMemory($title = null)
{
$mem = (double) xdebug_memory_usage() / (double) (1024 * 1024);
$mem = number_format($mem, 5) . ", " . time();
echo "{$title}: {$mem}<p>";
flush();
}
开发者ID:ksecor,项目名称:civicrm,代码行数:7,代码来源:System.php
|
请发表评论