Home  >  Article  >  Backend Development  >  Test code efficiency

Test code efficiency

WBOY
WBOYOriginal
2016-07-25 08:50:341085browse
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)< 10000)
  20. {
  21. $str.=getRandNum(1);
  22. }
  23. report($start);
复制代码


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn