Home > Backend Development > PHP Tutorial > Test code efficiency

Test code efficiency

WBOY
Release: 2016-07-25 08:50:34
Original
1132 people have browsed it
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);
复制代码


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template