當前位置:名人名言大全網 - 短信平臺 - 如何有效用PHP分析超大日誌(2G)

如何有效用PHP分析超大日誌(2G)

這個辦法可以提高壹些效率: 先把結果存在變量裏, 全部讀取後再存盤.

即把這段代碼:

if (fwrite($handle_result, $buffer) === FALSE) {

echo "1 record failed to write into log.

";

}

else

{

echo "1 record susseccful to write into log.

";

}

替換成:

$result .= $buffer . "\r\n";

$i++;

然後在while循環之前加上:

/*初始化變量*/

$result = "";

$i = 0;

在循環結束後加上:

if (fwrite($handle_result, $result) === FALSE) {

echo "Failed to write into log.

";

}

else

{

echo "$i records have been written into log susseccfully.

";

}