我的博客| Blog
- ·微信小程序错误:VM564:...
- ·mongodb3.2设置密码...
- ·单行滚动代码-单行滚动效果
- ·自己动手制作图形字体,以便于...
- ·MySQL无限级分类PHP按...
- ·Windows下的Apach...
- ·如何将网站上的文章分享到微信...
- ·PHP实现自动获取本月第几个...
联系我| Contact Me
- 电话:18681257080
- QQ:271538869
- 邮编:518020
- 信箱:service@08321.org
- 地址:四川省内江市资中县
诚信稳健,和谐共赢
- 以诚信为立世之本,在稳健的基础上,不断寻求创新与突破。
- 以务实严谨、精微细致的专业精神,为客户做最优质的策划,实现效果最大化。
成功,依稀可见
- 为什么成功依稀可见?
- 依希认为:每一人都有成功的机会,只要我们愿意付出努力,成功就在我们的前方。所以:成功,依稀可见!
我的博客
查看PHP程序执行时间类,PHP执行效率函数
来源:本站编辑 发布日期:2010-10-19 已有 人浏览过此信息
PHP程序的执行效率一直是大家比较关心的问题,下面放一个自定义类(即:查看PHP程序执行时间类,PHP执行效率函数)供大家测试一下你的PHP程序到底在服务器上花了多少时间。
代码如下:
<?php
class timer {
var $StartTime = 0;
var $StopTime = 0;
var $TimeSpent = 0;
function start(){
$this->StartTime = microtime();
}
function stop(){
$this->StopTime = microtime();
}
function spent() {
if ($this->TimeSpent) {
return $this->TimeSpent;
} else {
$StartMicro = substr($this->StartTime,0,10);
$StartSecond = substr($this->StartTime,11,10);
$StopMicro = substr($this->StopTime,0,10);
$StopSecond = substr($this->StopTime,11,10);
$start = floatval($StartMicro) + $StartSecond;
$stop = floatval($StopMicro) + $StopSecond;
$this->TimeSpent = $stop - $start;
return round($this->TimeSpent,8).'秒';
}
} // end function spent();
} //end class timer;
$foo='abcd';
$timer = new timer;
$timer->start();
if (!isset($foo{5})) { echo 'Foo is too short';}
$timer->stop();
echo '运行时间为 ',$timer->spent()
unset($timer);
?>
代码如下:
<?php
class timer {
var $StartTime = 0;
var $StopTime = 0;
var $TimeSpent = 0;
function start(){
$this->StartTime = microtime();
}
function stop(){
$this->StopTime = microtime();
}
function spent() {
if ($this->TimeSpent) {
return $this->TimeSpent;
} else {
$StartMicro = substr($this->StartTime,0,10);
$StartSecond = substr($this->StartTime,11,10);
$StopMicro = substr($this->StopTime,0,10);
$StopSecond = substr($this->StopTime,11,10);
$start = floatval($StartMicro) + $StartSecond;
$stop = floatval($StopMicro) + $StopSecond;
$this->TimeSpent = $stop - $start;
return round($this->TimeSpent,8).'秒';
}
} // end function spent();
} //end class timer;
$foo='abcd';
$timer = new timer;
$timer->start();
if (!isset($foo{5})) { echo 'Foo is too short';}
$timer->stop();
echo '运行时间为 ',$timer->spent()
unset($timer);
?>
上一条:何为一个“丰满”的设计?
下一条:php生成随机密码的几种方法
