编辑::哦,我忘了
@H_502_14@class Test1{ public static function test(){ for($i=0; $i<=1000; $i++) $j += $i; } } class Test2{ public function test() { for ($i=0; $i<=1000; $i++){ $j += $i; } } }
对于这个算法
$time_start = microtime(); $test1 = new Test2(); for($i=0; $i<=100;$i++) $test1->test(); $time_end = microtime(); $time1 = $time_end - $time_start; $time_start = microtime(); for($i=0; $i<=100;$i++) Test1::test(); $time_end = microtime(); $time2 = $time_end - $time_start; $time = $time1 - $time2; echo "Difference: $time";
我有结果
Difference: 0.007561