Files
@ a45f0dabc59c
Branch filter:
Location: hot67beta/libraries/joomla/error/profiler.php - annotation
a45f0dabc59c
3.7 KiB
text/x-php
mneh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 | <?php
/**
* @version $Id: profiler.php 10707 2008-08-21 09:52:47Z eddieajau $
* @package Joomla.Framework
* @subpackage Error
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
/**
* Utility class to assist in the process of benchmarking the execution
* of sections of code to understand where time is being spent.
*
* @package Joomla.Framework
* @subpackage Error
* @since 1.0
*/
class JProfiler extends JObject
{
/**
*
* @var int
*/
var $_start = 0;
/**
*
* @var string
*/
var $_prefix = '';
/**
*
* @var array
*/
var $_buffer= null;
/**
* Constructor
*
* @access protected
* @param string Prefix for mark messages
*/
function __construct( $prefix = '' )
{
$this->_start = $this->getmicrotime();
$this->_prefix = $prefix;
$this->_buffer = array();
}
/**
* Returns a reference to the global Profiler object, only creating it
* if it doesn't already exist.
*
* This method must be invoked as:
* <pre> $browser = & JProfiler::getInstance( $prefix );</pre>
*
* @access public
* @param string Prefix used to distinguish profiler objects.
* @return JProfiler The Profiler object.
*/
function &getInstance($prefix = '')
{
static $instances;
if (!isset($instances)) {
$instances = array();
}
if (empty($instances[$prefix])) {
$instances[$prefix] = new JProfiler($prefix);
}
return $instances[$prefix];
}
/**
* Output a time mark
*
* The mark is returned as text enclosed in <div> tags
* with a CSS class of 'profiler'.
*
* @access public
* @param string A label for the time mark
* @return string Mark enclosed in <div> tags
*/
function mark( $label )
{
$mark = $this->_prefix." $label: ";
$mark .= sprintf('%.3f', $this->getmicrotime() - $this->_start) . ' seconds';
if ( function_exists('memory_get_usage') ) {
$mark .= ', '.sprintf('%0.2f', memory_get_usage() / 1048576 ).' MB';
}
$this->_buffer[] = $mark;
return $mark;
}
/**
* Get the current time.
*
* @access public
* @return float The current time
*/
function getmicrotime()
{
list( $usec, $sec ) = explode( ' ', microtime() );
return ((float)$usec + (float)$sec);
}
/**
* Get information about current memory usage.
*
* @access public
* @return int The memory usage
* @link PHP_MANUAL#memory_get_usage
*/
function getMemory()
{
static $isWin;
if (function_exists( 'memory_get_usage' )) {
return memory_get_usage();
} else {
// Determine if a windows server
if (is_null( $isWin )) {
$isWin = (substr(PHP_OS, 0, 3) == 'WIN');
}
// Initialize variables
$output = array();
$pid = getmypid();
if ($isWin) {
// Windows workaround
@exec( 'tasklist /FI "PID eq ' . $pid . '" /FO LIST', $output );
if (!isset($output[5])) {
$output[5] = null;
}
return substr( $output[5], strpos( $output[5], ':' ) + 1 );
} else {
@exec("ps -o rss -p $pid", $output);
return $output[1] *1024;
}
}
}
/**
* Get all profiler marks.
*
* Returns an array of all marks created since the Profiler object
* was instantiated. Marks are strings as per {@link JProfiler::mark()}.
*
* @access public
* @return array Array of profiler marks
*/
function getBuffer() {
return $this->_buffer;
}
}
|