Copy code The code is as follows:
/**
* Recording and statistics time (microseconds) and memory usage
* Usage:
* <br> * G('begin'); // Recording start mark bit<br> * // ... Interval running code <br> * G('end'); // Record end tag bit <br> * echo G('begin','end',6); // Statistics interval running The time is accurate to 6 decimal places <br> * echo G('begin','end','m'); // Statistical interval memory usage <br> * If the end mark bit is not defined, it will automatically use the current As a mark bit<br> * The statistical memory usage requires MEMORY_LIMIT_ON constant to be valid <br> *
* @param string $start start tag
* @param string $end end tag
* @param integer|string $dec decimal place or m
* @return mixed
*/
function G($start,$ end='',$dec=4) {
static $_info = array();
static $_mem = array();
if(is_float($end)) { // Recording time
$_info[$start] = $end;
}elseif(!empty($end)){ // Statistics time and memory usage
if(!isset($_info[$end])) $ _info[$end] = microtime(TRUE);
if(MEMORY_LIMIT_ON && $dec=='m'){
if(!isset($_mem[$end])) $_mem[$end] = memory_get_usage();
return number_format(($_mem[$end]-$_mem[$start])/1024); _info[$start]),$dec);
} }
}else{ // Record time and memory usage
$_info[$start] = microtime(TRUE);
if (MEMORY_LIMIT_ON) $_mem[$start] = memory_get_usage();
}
}
http://www.bkjia.com/PHPjc/741258.html
www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/741258.htmlTechArticleCopy code The code is as follows: /** * Record and count time (microseconds) and memory usage* How to use : * code * G('begin'); // Record start mark bit* // ...Interval running code*...