ADSFASFDA

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
魔法函数执行时间0.635
<?php

class Test{
    private $var='123';
    public function __get($name)
    {
        return $this->var;
    }

}
function current_time(){
    list($usec,$sec)= explode(' ',microtime());
    return ((float)$usec+(float)$sec);
}
$_start=current_time();
$i=0;
while ($i<20000){
    $i++;
    $t=new Test();
    $t->var;
}
$_end=current_time();
header('Content-Type:text/html;charset=utf');
echo '执行时间'.number_format($_end-$_start,3);
View Code

public直接获取执行时间为

<?php

class Test{
   // private $var='123';
    public $var='123';
 /*   public function __get($name)
    {
        return $this->var;
    }*/

}
function current_time(){
    list($usec,$sec)= explode(' ',microtime());
    return ((float)$usec+(float)$sec);
}
$_start=current_time();
$i=0;
while ($i<20000){
    $i++;
    $t=new Test();
    $t->var;
}
$_end=current_time();
header('Content-Type:text/html;charset=utf');
echo '执行时间'.number_format($_end-$_start,3);
View Code

 

posted on 2017-03-07 01:11  778323309  阅读(95)  评论(0编辑  收藏  举报