最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

全局記錄程序片段的運(yùn)行時(shí)間 正確找到程序邏輯耗時(shí)多的斷點(diǎn)

 更新時(shí)間:2011年01月06日 17:09:01   作者:  
全局記錄程序片段的運(yùn)行時(shí)間 正確找到程序邏輯耗時(shí)多的斷點(diǎn),需要的朋友可以參考下。
復(fù)制代碼 代碼如下:

// 定義全局變量 記錄時(shí)間
$_timer_id = 0;
// 函數(shù)設(shè)置全局變量 記錄各個(gè)斷點(diǎn)的運(yùn)行所需時(shí)間
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++;
}
}
// 把全局運(yùn)行時(shí)間情況輸出
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;
}
使用方法:
// 開(kāi)始時(shí)間
makeTimer( ' LINE:'.__LINE__ );
$imgstrpos = strpos($str, '<img'.$imgstr);
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.'<img '.$imgstr.'>'.$str_n." ";
makeTimer( ' LINE:'.__LINE__ );
// 記錄到日志中
error_log( traceTimer(), 3, '/tmp/'.basename(__FILE__).'.log' );
// 或者直接輸出
echo traceTimer();

at 2010-05-14 09:20

相關(guān)文章

最新評(píng)論

柘荣县| 黑河市| 岳阳市| 马山县| 尼木县| 高平市| 尼玛县| 米脂县| 保定市| 扶风县| 托克托县| 赣州市| 禹城市| 临湘市| 和平县| 宜兰市| 屏东县| 岑巩县| 长治市| 赞皇县| 周至县| 兴城市| 建湖县| 海兴县| 乃东县| 东源县| 石狮市| 芦溪县| 喀喇沁旗| 丹凤县| 齐河县| 宁夏| 阜阳市| 江城| 太湖县| 蓝山县| 无锡市| 崇阳县| 和龙市| 秀山| 聂拉木县|