measuring the elapsed time between code segments in PHP

后端 未结 7 1764
傲寒
傲寒 2020-12-15 19:32

From time time to time, I\'d like to be able to measure the elapsed time between two segments of code. This is solely to be able to detect the bottlenecks within the code an

7条回答
  •  太阳男子
    2020-12-15 20:12

    Something along these lines should work:

    $start = microtime(true); 
    
    // Do something
    sleep(2);
    
    $end = (microtime(true) - $start);
    echo "elapsed time: $end";
    

提交回复
热议问题