Created
January 12, 2016 08:31
-
-
Save huzemin/0f0c9e193d45af6e9217 to your computer and use it in GitHub Desktop.
Calculate what the function execute spend.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 计算函数的执行时间,可以用于性能统计 | |
* @param $function | |
* @param array $params | |
* @param int $times | |
* @return mixed | |
*/ | |
function cal_run_time($function, $params = array(), $times = 100) { | |
$_start = microtime(true); | |
for($i = 0; $i < $times; $i ++) { | |
call_user_func_array($function, $params); | |
} | |
$_end = microtime(true); | |
return $_end - $_start; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment