Php slow logon lag

I am developing a new section on my site, and I see a slight delay in logging in. it works fine on my computer, but when I put it on the server it works slower. the registration process is slower on the server and not on my cmoputer.

half a second to 1 second slower

I have doubts about my hosting, which is not as fast as they say, because it is fast on my computer.

Is there a way to track the speed of the server command line or a PHP I can run to find out what's wrong?

+6
source share
2 answers

Put these three lines of code in different places in your script (replacing "foo" with a description of where you put it in the code):

 $h = fopen('log.txt', 'a'); fwrite($h, 'foo: ' . microtime(true)); fclose(); 

Then run the script and you will see which part will be slow.

+10
source

At the top of the script, put

 <?php function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } $start_time = microtime_float(); 

and in the end

 $exec_time = microtime_float() - $start_time; echo 'Page loaded in: ' . $exec_time . 'seconds'; ?> 

Compare the local copy with the deleted copy.

0
source

Source: https://habr.com/ru/post/908194/


All Articles