Benchmarking PHP page load times

前端 未结 10 2025
借酒劲吻你
借酒劲吻你 2021-01-31 10:56

How could I measure the time taken to load a page (with various different PHP statements)?

Somewhat like the stats available here - http://talks.php.net/show/drupal08/24

10条回答
  •  有刺的猬
    2021-01-31 11:23

    Using microtime() PHP function you will know exactly how much time is needed for your PHP code to be executed. Follow the steps below to put the PHP code on your web page:

    Put the following code at the very top of your PHP page (if you measure the time needed for particular part of the code put this right before that PHP code part)

    
    

    The following code has to be put at the very end of the web page (or the end of the PHP code part)

    If not works use microtime(true) instead of microtime()

提交回复
热议问题