PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Nov 28, 2014 4:33 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat Dec 10, 2011 1:43 am 
Offline
Forum Commoner

Joined: Sat May 19, 2007 4:10 am
Posts: 50
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
Syntax: [ Download ] [ Hide ]
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.


Top
 Profile  
 
PostPosted: Mon Dec 26, 2011 5:01 am 
Offline
Forum Commoner

Joined: Sat May 19, 2007 4:10 am
Posts: 50
hi,

any comments ?? :D I am attaching am screen shot of the actual view of a trace produced by the profiler..


Attachments:
profiler-ss.png
profiler-ss.png [ 156.54 KiB | Viewed 2767 times ]
Top
 Profile  
 
PostPosted: Fri Jan 06, 2012 6:36 am 
Offline
DevNet Resident
User avatar

Joined: Sun Sep 03, 2006 5:19 am
Posts: 1579
Location: Sofia, Bulgaria
Can you give a short description on how this thing works? Would it work without using your framework?


Top
 Profile  
 
PostPosted: Wed Jan 11, 2012 12:25 am 
Offline
Forum Commoner

Joined: Sat May 19, 2007 4:10 am
Posts: 50
This is a profiler that does not require xdebug and does not require to add additional profiling code around your functions. This profiler works by modifying included files on the fly to add the profiler function calls and other required statements for profiling. The actual file is untouched. Just the way php sees the file is changed. So it can measure the time spent is every invocation of a function,memory used and arguments passed to and values returned from functions. It can also generate a trace of the program execution. The dump data is written into 50 files( can be configured) and is viewed the trace viewer.

To use this just delete the dump from last trace using the delete last trace menu item from profile menu. The next page you take in browser will be profiled. So after taking a page, if you go back to the view last trace page, you can see the data collected. You can click on the function names to dig down deeper into the execution level/ function calls. You can also track any files included also.

PS: I have searched for ages for something like that SQL injection article in your signature. Its great.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group