首页 >后端开发 >php教程 >测试代码效率

测试代码效率

WBOY
WBOY原创
2016-07-25 08:50:341116浏览
begin($start);
report($start);
  1. function begin(&$start) {
  2. $tmp = gettimeofday();
  3. $start = $tmp[usec];
  4. }
  5. function report($start) {
  6. $tmp = gettimeofday();
  7. $now = $tmp[usec];
  8. echo "time consuming: ";
  9. echo $now - $start;
  10. echo "
    ";
  11. }
  12. function getRandNum($length = 8) {
  13. $salt = substr(uniqid(rand()), -$length);
  14. return $salt;
  15. }
  16. $start = 0;
  17. begin($start);
  18. $str="";
  19. while (strlen($str){
  20. $str.=getRandNum(1);
  21. }
  22. report($start);
复制代码


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn