我的应用程序已经使用了 6 个月,而且很久以前我就不再被要求解决新的错误了.. 生活很棒 :)
现在我完成了其他项目的工作,并希望加快我的应用程序的速度。
问题
EG:我有一个像这样的非常简单的函数,我使用 AJAX 调用它。
在我看到的浏览器控制台中,该函数需要 700 毫秒才能完成。我计算了触发函数主体中的实际代码需要多少毫秒。毫不奇怪,只有大约 100 毫秒,这是可以的。
public function getObjVisibility()
{
$start = round( microtime( true ) * 1000 );
$this->autoRender = false;
$tmp = $this->Obj->find ( 'first', array
(
'conditions' => array
(
'obj_id' => $_POST['id']
),
'fields' => array
(
'visible'
)
)
);
$result = $tmp['Obj']['visible']; //added field so I could count even the assigning
$end = round( microtime ( true ) * 1000 );
fb::log( "time: ", $start - $end ); // firePHP logging to console
return $tmp['Obj']['visible'];
}
所以这个函数最多需要大约 100 毫秒,至少需要大约 700 毫秒。
你们中有人知道发生了什么吗?我无法为谷歌制定一个合理的问题给我一个合理的答案,所以我问你们:)