Q: Test PHP efficiency? I am working on is a website which features:


*

*user signup

*user login

*add friend/delete friend

*karma

*hotlinks (user can add any page to there nav)

*admin panel (available to admin personnel only)

*user email system


I have created all of these things and they all work how they should.  How I can test the php scripts--not the load time of the page, but the actual runtime of each script on each page?

A: You'll want to invoke micro time.
At the beginning of your script:
$startTime = microtime( true );

At the end of the script, and be sure to use this variable method or else you may get a negative:
$endTime = microtime( true );
echo( "Time taken: " . ( $endTime - $startTime ) );

To get this time in miliseconds, you can do:
$parseTime = $endTime - $startTime;
$timeTaken = number_format( ( $parseTime * 1000 ), 3 );
echo( $timeTaken . "ms" );

One good way to benchmark is just take a look at the average run time of some of the more popular PHP applications. Many put parse time in the footer.

A: The best tool with web interface for profiling php is XHPROF.
Look at http://www.mirror.facebook.net/facebook/xhprof/doc.html . 
However xdebug gets more accurate results than xprof. But in this case you will have to download a special program to look through xdebug report and on production this one is not applicable. Because you will download xdebug report to local machine but with xhprof you will look at profiler page in real time.
