我有一个大约 6350268 个字符的字符串,当我将它们输出到浏览器时,它至少需要 700 毫秒,但通常需要 900 毫秒到 1000 毫秒的额外执行时间来输出它。
一代只占用了大约300ms,但加起来几乎是一整秒。
有没有办法加快回声输出?还是受输出到的浏览器的限制?
// What this code does is take about 20.000 urls in the database and
// and transform it into a collapsable folder tree
// this process generates about 6300000 characters in about 300ms.
$this->benchmark->mark('code_start');
$query = $this->db->query("SELECT `url` from `site_pages` WHERE `url` not like '' order by `url` ASC");
$arr = array();
foreach($query->result() as $result)
{
$arr[$result->url] = $result->url;
}
$tree = $this->explodeTree($arr,'/',true);
$str = $this->plotTree($tree);
echo $str;
$this->benchmark->mark('code_end');
echo $this->benchmark->elapsed_time('code_start', 'code_end');
echo "<P>done";