繁体   English   中英

OpenCart类别页面加载时间

[英]OpenCart category page load times

我对脚本进行了一些基准测试,该脚本加载了类别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查询和图像大小调整(如果需要)。 我在此页面上运行了基准测试:

http://www.hollywoodcollectibles.com/baseball/autographed-baseball-balls

您会注意到,加载该页面需要花费10秒钟以上的时间,并且大部分时间用于请求而不是响应。 因此,瓶颈实际上根本不在SQL中。 包含少量产品的大多数其他类别根本没有遇到此瓶颈。

我运行了另一个基准测试,这次测量渲染实际输出所需的时间, $this->response->setOutput($this->render());

Array
(
    [0] => 1386296946.8589
    [1] => 1386296964.206
)

现在,我们到了某个地方。 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(),但这仅用于我相信的分页。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM