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
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
There are many ways to do this. I've personally been a fan of using microtime in the following way:
That will give you microsecond accuracy.
If you are writing command-line scripts (like Facebook puzzles), you can use just time.
I forgot about the method of monitoring page load times (from a browser). You can use the NET tab from Firebug (for Firefox) to do just that. It will let you watch the various file loads (AJAX, JS, CSS, Images, etc.).
Put the following code at the top of your PHP page.
The following code has to be put at the end of your page.
Note: If you measure the time for particular part of the code put this right start and last PHP code part.
The Output in that presentation seem to be copied from Siege (http://www.joedog.org/index/siege-home).
Another quite useful tool for "real world" performance testing your whole application stack is Firebug (http://getfirebug.com/) and YSlow (http://developer.yahoo.com/yslow/)
Try https://github.com/fotuzlab/appgati
It allows to define steps in the code and reports time, memory usage, server load etc between two steps.
Something like:
Sample output array:
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()
You can use microtime() at the start of processing and at end of output, then calculate the difference and convert it to seconds if wanted.
This will only measure the execution time for PHP side, not the whole page load time at it seems to be in your link, but it will able you to compare various methods performance, for instance.