Php OpenCart类别页面加载时间
我对从一个类别加载所有产品的脚本做了一些基准测试,Php OpenCart类别页面加载时间,php,opencart,Php,Opencart,我对从一个类别加载所有产品的脚本做了一些基准测试,route=product/category。我在整个脚本中插入了几个microtime函数,得到了以下结果: Array ( [0] => 1386295629.1175 [1] => 1386295629.1556 [2] => 1386295629.1562 [3] => 1386295629.1562 [4] => 1386295629.4826 [5] =&g
route=product/category
。我在整个脚本中插入了几个microtime函数,得到了以下结果:
Array
(
[0] => 1386295629.1175
[1] => 1386295629.1556
[2] => 1386295629.1562
[3] => 1386295629.1562
[4] => 1386295629.4826
[5] => 1386295629.49
[6] => 1386295629.4908
[7] => 1386295629.491
)
从开始到结束,加载整个页面的数据需要0.3735秒。这包括所有SQL查询和图像大小调整(如果需要)。我在这个页面上运行了基准测试:
您会注意到,加载该页面需要10秒以上的时间,大部分时间用于请求而不是响应。因此,瓶颈实际上根本不在SQL中。大多数其他类别的产品数量较少,根本没有遇到这个瓶颈
我运行了另一个基准测试,这次测量了渲染实际输出所需的时间,$this->response->setOutput($this->render())代码>
现在,我们有进展了。Opencart花了17.34秒渲染输出
在这之后,我迷路了。有人能告诉我Opencart中的$this->render()
函数在哪里,并可能给我任何其他的建议来查找瓶颈吗?我不知道这是否对您有帮助,但该函数位于system/engine/controller.php
protected function render() {
foreach ($this->children as $child) {
$this->data[basename($child)] = $this->getChild($child);
}
if (file_exists(DIR_TEMPLATE . $this->template)) {
extract($this->data);
ob_start();
require(DIR_TEMPLATE . $this->template);
$this->output = ob_get_contents();
ob_end_clean();
return $this->output;
} else {
trigger_error('Error: Could not load template ' . DIR_TEMPLATE . $this->template . '!');
exit();
}
}
system/library/pagination.php
中还有另一个函数render(),但我相信这只是为了分页 现在删除缓存文件并进行基准测试;-)不会是0.3735
秒;-)不过有一个问题:看看这么多的类别-你是否安装了一些类别产品计数删除扩展??如果没有,请尝试一个,然后返回结果;-)是的,有一个vqmod可以删除类别计数。在我做了任何微小的改变之后,我虔诚地清除缓存。
protected function render() {
foreach ($this->children as $child) {
$this->data[basename($child)] = $this->getChild($child);
}
if (file_exists(DIR_TEMPLATE . $this->template)) {
extract($this->data);
ob_start();
require(DIR_TEMPLATE . $this->template);
$this->output = ob_get_contents();
ob_end_clean();
return $this->output;
} else {
trigger_error('Error: Could not load template ' . DIR_TEMPLATE . $this->template . '!');
exit();
}
}