I have a PHP script being loaded by JS through JQuery's $.ajax
.
I measured the execution time of the PHP script using:
$start = microtime(); // top most part of code
// all other processes that includes AES decryption
$end = microtime(); // bottom part of code
file_put_contents('LOG.TXT','TIME IT TOOK: '.($end-$start)."\n",FILE_APPEND);
It measured somewhere less than 1 second. There are no prepend/append PHP scripts.
In the JS $.ajax
code, I have measured the execution time by:
success: function(response) {
console.log(date('g:i:s a') + ' time received\n');
// all other processes including AES decryption
console.log(date('g:i:s a') + ' time processed\n');
}
The time is the same for the time received and the time processed.
However, when I check the Chrome Developer Tools, it claims that the PHP script loaded for about 8 seconds.
What could be wrong in how I measured these things? I'm certain that PHP is loading fast but how come Chrome reports that it took more than 8 seconds?
I'm using localhost and my web server is fast and this is the only time I encountered this problem. All other AJAX calls are fast.