- 论坛徽章:
- 1
|
本帖最后由 yakczh_cu 于 2014-06-16 12:32 编辑
test1.php
- <?php
- function test(){
- $i=100;
- $arr=array();
- do { array_push($arr,$i); }while ($i--);
- }
- $func='test';
- define('REPEAT',10000*10);
- $cnt=REPEAT;
- $start=microtime(true);
- do { $func(); } while ($cnt--);
- $end=microtime(true);
- echo "\ncall_by_name exec time " ,$end-$start;
-
- $cnt=REPEAT;
- $start=microtime(true);
- do { call_user_func($func); }while ($cnt--);
- $end=microtime(true);
- echo "\ncall_user_func exec time " ,$end-$start;
- ?>
复制代码 test2.php
- <?php
- function test(){
- $i=100;
- $arr=array();
- do { array_push($arr,$i); }while ($i--);
- }
- $func='test';
- define('REPEAT',10000*10);
- $cnt=REPEAT;
- $start=microtime(true);
- do { call_user_func($func); }while ($cnt--);
- $end=microtime(true);
- echo "\ncall_user_func exec time " ,$end-$start;
- $cnt=REPEAT;
- $start=microtime(true);
- do { $func(); } while ($cnt--);
- $end=microtime(true);
- echo "\ncall_by_name exec time " ,$end-$start;
-
复制代码 |
|