Copy Code code as follows:
Define global variable record time
$_timer_id = 0;
function to set global variables to record the time required for each breakpoint to run
function Maketimer ($notes, $onOff =false)
{
if ($ONOFF)
{
Global $_timer_id;
$GLOBALS [' timer '][$_timer_id][0] = Microtime (TRUE);
$GLOBALS [' timer '][$_timer_id][1] = $notes;
$_timer_id++;
}
}
The global run time condition output
function Tracetimer ()
{
$timer _str = ';
$G _timer = count ($GLOBALS [' Timer '])-1;
if ($G _timer>0)
{
for ($i =0; $i < $G _timer; $i + +)
{
$dif _time = Number_format ($GLOBALS [' Timer '] [$i +1][0]-$GLOBALS [' Timer '] [$i][0]), 3;
$timer _str. = ' dif: '. $dif _time. ' '. $GLOBALS [' Timer '] [$i][1]. " \ n ";
}
$dif _time = Number_format ((microtime (TRUE)-$GLOBALS [' Timer '] [$G _timer][0]), 3;
$timer _str. = ' dif: '. $dif _time. ' '. $GLOBALS [' Timer '] [$G _timer][1]. " \ n ";
}
return $timer _str;
}
How to use:
Start time
Maketimer (' line: '. __line__);
$imgstrpos = Strpos ($str, ' Maketimer (' line: '. __line__);
$str _p = substr ($str _noimg, 0, $imgstrpos);
Maketimer (' line: '. __line__);
$str _n = substr ($str _noimg, $imgstrpos, strlen ($str _noimg));
Maketimer (' line: '. __line__);
$pst _exc_imgs = $str _p. ' '. $str _n. " ";
Maketimer (' line: '. __line__);
Record to log
Error_log (Tracetimer (), 3, '/tmp/'. basename (__file__). Log ");
or direct output
Echo Tracetimer ();
At 2010-05-14 09:20