确定PHP到目前为止执行多长时间 [英] Determine how long PHP executed so far

查看:83
本文介绍了确定PHP到目前为止执行多长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要确定一个PHP函数到目前为止运行了多久。



有什么方法可以找出一些PHP代码需要运行多长时间? / p>

我使用zend框架。 调用 microtime(true)函数以百万分辨率获取当前时间。

  <? php 
$ startTime = microtime(true);

/ *东西正在进行* /

回声已用时间为:。 (microtime(true) - $ startTime)。seconds;


I need to determine how long a PHP function has been running so far.

What are some options to find out how long some PHP code takes to run?

I'm using zend framework.

解决方案

Call microtime(true) function to fetch current time with milisecond resolution.

<?php
$startTime = microtime(true);

/*stuff is going on*/

echo "Elapsed time is: ". (microtime(true) - $startTime) ." seconds";

这篇关于确定PHP到目前为止执行多长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆