Board index   FAQ   Search  
Register  Login
Board index PHP Your Scripts

An xdebug like php profiler without xdebug

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

An xdebug like php profiler without xdebug

Postby sandeepcr » Sat Dec 10, 2011 8:54 am

Hi there,

I have made a profiler for a new php framework I am working on. I need to know if a profiler like this already exists for php.

This profiler is a bit like xdebug. But it does not need any extra extensions.

This also does not need you to add any profiling code to your functions.

Here is the framework -ModuleR,

http://moduler.pagodabox.com

To see a sample of the profilers trace go to

http://moduler.pagodabox.com/index.php/trace/lastTrace

Profiler can Profile and trace your functions without adding a single line of profiling code.

The Profile includes

The time spent in function.
The memory used by the function.
The arguments passed to the functions.
The return values of the function.

To see a sample of the profilers trace go to

http://moduler.pagodabox.com/index.php/trace/lastTrace

You can click on function names to show deeper function calls. You can click on the unserialize link to show arguments and return values.

To try out the profiler it is better if you download the framework. Installtion is as simple as

downloading the tar archive from http://moduler.pagodabox.com/moduleR.tar

renaming config.template.php and routes.template.php in config directory to config.php and routes.php.

Edit config.php to match your file path.

give write permissions to scratch directory.

Thats all...

Now to see the profiler in action,

Open any of the module controller files, say modules/builder/builder.php.

Add a new method test_function to the builder class.
Add some code that creates some delay and take some memory. for eg

Code: Select all
function test_function()
{
sleep(2);
$str = str_repeat('t',1000);
}


now delete the last dump by going to menu link, profiler->delete last trace.

Then take the page index.php/builder/test_function .

Now if all goes well, profiler should have written a lot of files to the scratch/dump directory. You can see the profile by taking from menu, Profiler=>view last trace.

Now the first level of function calles will be shown. Here the last one will be core::response(). If you click on it it will expand to show function calls from that function. That should include our new function builder::test_function(). Besides the function name will be the time spent inside that function, which should be close to 2 seconds.and a memory use of nearly 2000bytes.Increase the sleep time and string length to try the profileres accuaracy.

Please let me know what you think.

Thank you.
Sandeep.
sandeepcr
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sat Dec 10, 2011 8:27 am

Return to Your Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.