本文介绍了Codeigniter基准测试,这些ms来自何处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对网站进行基准测试.

I'm in the process of benchmarking my website.

class Home extends Controller {

    function Home()
    {
        parent::Controller();
        $this->benchmark->mark('Constructor_start');

        $this->output->enable_profiler(TRUE);
        $this->load->library ('MasterPage');

        $this->benchmark->mark('Constructor_end');
    }

    function index()
    {
        $this->benchmark->mark('Index_start');

        $this->masterpage->setMasterPage('master/home');
        $this->masterpage->addContent('home/index', 'page');
        $this->masterpage->show();

        $this->benchmark->mark('Index_end');
    }
}

这些是结果:

我了解以下内容:

  • 加载时基类(0.0076)
  • 构造函数(0.0007)
  • 索引(0.0440)

但是其余时间是哪里来的?

推荐答案

我尚未对基于CI的网站进行很多基准测试,但0.4545的速度似乎并不快.

I haven't done a lot of benchmarking of CI-powered sites, but 0.4545 doesn't seem very fast.

在控制器执行时间(但不在您定义的基准测试范围内)下发生的一件事是自动加载config/autoload.php文件中定义的所有内容.如果您要在其中加载大量库或模型,那么这会增加控制器执行时间,而没有任何显而易见的原因.

One thing that occurs under the umbrella of Controller Execution Time (but outside your custom defined benchmarks) is the autoloading of everything defined in the config/autoload.php file. If you're loading numerous libraries or models there, that would add to your Controller Execution Time without any immediately obvious reason.

这篇关于Codeigniter基准测试,这些ms来自何处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 09:04