檢測到不相容的鍵盤驅動程式 全域記錄程式片段的已耗用時間 正確找到程式邏輯耗時多的斷點

來源:互聯網
上載者:User
複製代碼 代碼如下:


// 定義全域變數 記錄時間
$_timer_id = 0;
// 函數設定全域變數 記錄各個斷點的運行所需時間
function makeTimer( $notes, $ )
{
if( $onOff )
{
global $_timer_id;
$GLOBALS['timer'][$_timer_id][0] = microtime(TRUE);
$GLOBALS['timer'][$_timer_id][1] = $notes;
$_timer_id++;
}
}
// 把全域已耗用時間情況輸出
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;
}
使用方法:
// 開始時間
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__ );
// 記錄到日誌中
error_log( traceTimer(), 3, '/tmp/'.basename(__FILE__).'.log' );
// 或者直接輸出
echo traceTimer();


at 2010-05-14 09:20

以上就介紹了檢測到不相容的鍵盤驅動程式 全域記錄程式片段的已耗用時間 正確找到程式邏輯耗時多的斷點,包括了檢測到不相容的鍵盤驅動程式方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.