Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何知道特定函数的运行时间?_Php_Zend Framework_Function_Runtime - Fatal编程技术网

Php 如何知道特定函数的运行时间?

Php 如何知道特定函数的运行时间?,php,zend-framework,function,runtime,Php,Zend Framework,Function,Runtime,我正在使用PHP和Zend。我的一些代码执行时间太长。了解特定函数/构造函数消耗了多少时间的最佳方法是什么 例如: 我调用的函数如下: $insuranceModel = new Model_Insurance_Object(); $insurances = $insuranceModel->getInsurancesList(); 模型\保险\对象类中的getInsurancesList函数 我应该实施什么?我应该放在哪里 谢谢我有一份工作。看来,这正是你想要的。@KingChurch

我正在使用PHP和Zend。我的一些代码执行时间太长。了解特定函数/构造函数消耗了多少时间的最佳方法是什么

例如:

我调用的函数如下:

$insuranceModel = new Model_Insurance_Object();
$insurances = $insuranceModel->getInsurancesList();
模型\保险\对象类中的getInsurancesList函数

我应该实施什么?我应该放在哪里


谢谢

我有一份工作。看来,这正是你想要的。

@KingChurch回答得很好!:D如果您不想使用.dll安装路径,还可以编写一个小benchit,它可以乘以任何代码段的运行时间

function benchit()
{
    list($msec, $sec) = explode(' ', microtime());
    return (double)$sec + (double)$msec;
}

$start = benchit();
// ... Some code here
$end = benchit();
也很有用,可能是
function benchit()
{
    list($msec, $sec) = explode(' ', microtime());
    return (double)$sec + (double)$msec;
}

$start = benchit();
// ... Some code here
$end = benchit();