来源:4-1 减少PHP魔法函数的使用

跌落尘层的王者

2014-10-19 14:18

<?php
 header('Content-type: text/html; charset=utf8');
function current_time(){
    list( $usec ,$sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}
class Test{
	public $var = "123";
	public function __get($varname){
		return $this->var;
	}
}
$start = current_time();
$i = 0;
while ($i<10000) {
	$i++;
	$test = new Test();
	$test->var;
}
$end = current_time();
echo "Lost Time: ". number_format($end - $start,3)*1000;
echo "\n";

?>


写回答 关注

0回答

还没有人回答问题,可以看看其他问题

性能优化之PHP优化

带你打造高速高效的PHP项目,由浅入深带你进一步探索php优化项目

37099 学习 · 109 问题

查看课程

相似问题