{
$fp = fopen($tagsPath, "r");
$arrconf = array ();
if ($fp)
{
while (!feof($fp))
{
$line = fgets($fp, 1024);
$line = trim($line);
$rows = explode("#", $line);
$coumns = explode("=", trim($rows[0]));
if(""!=trim($coumns[0]))
{
$arrconf[trim($coumns[0])] = trim($coumns[1]);
}
}
}
return $arrconf;
}
}
(4)对getForbiddenTags函数进行分析,其中的PHP函数trim被调用了16827次。
(5)可能造成瓶颈的原因:
要过滤的156个关键字逐行存放在/usr/local/apache/template/tags/forbidden_tags.txt文件中,文本数据库的效率不高。
逐行读取函数fgets、以及去除字符串两边的空白或者指定的字符的函数trim在高负载下的效率低,可以测试fopen、fread、fscanf之类的文件读取函数,对比一下。







