Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to measure the speed of a website using php? [closed]

Tags:

php

pagespeed

I have a list of URLs in an array and want to check how long it takes to access each webpage. Can you please tell me if it is possible to find a speed of a webpage using PHP? I would really appreciate it if you can show it to me with an example

like image 348
Hope S Avatar asked Dec 18 '25 20:12

Hope S


1 Answers

If your web site runs entirely on php, you can measure how long the php script works. If you want to measure the response time of your server you can use firefox or chrome developer menu options which display the total access time to the server.

To measure the lifetime of a php script: The php function microtime() is a handy tool for time profiling. At the entry of your site add:

 $startTime = microtime(true);
 register_shutdown_function('measureTime');

 function measureTime(){
 global $startTime;
     $execTime = microtime(true)-$startTime;
     echo "Script execution time: $execTime seconds.";
 }
like image 109
Volkan Avatar answered Dec 21 '25 12:12

Volkan