473,326 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

PHP profiler

I'm looking for a GPL licensed PHP profiler. The best thing around,
except the commercial goodies from NuSphere, seems to be Carl Taylor's
toolkit at http://www.adepteo.net/profiler/index.php
Any experiences? Does anybody here uses profiler to see where the
application time is spent and which components need fine tuning?

--
http://www.mgogala.com

Dec 17 '05 #1
6 2894
Here is a simple profiler I wrote. It uses a tick function to measure
the time expired between each PHP operation and debug_back_trace() to
find out where it occurs. Kinda neat as you don't have to make much
modification. Just include it at the beginning of the script, then at
the end, call __profile__('get') to obtain the profile data--an
associative array of percentages keyed by function names.

profiler.php:
<?php

function __profiler__($cmd = false) {
static $log, $last_time, $total;
list($usec, $sec) = explode(" ", microtime());
$now = (float) $usec + (float) $sec;
if($cmd) {
if($cmd == 'get') {
unregister_tick_function('__profile__');
foreach($log as $function => $time) {
if($function != '__profile__') {
$by_function[$function] = round($time / $total * 100, 2);
}
}
arsort($by_function);
return $by_function;
}
else if($cmd == 'init') {
$last_time = $now;
return;
}
}
$delta = $now - $last_time;
$last_time = $now;
$trace = debug_backtrace();
$caller = $trace[1]['function'];
@$log[$caller] += $delta;
$total += $delta;
}

__profiler__('init');
register_tick_function('__profiler__');
declare(ticks=1);

?>

Dec 18 '05 #2
Forgot to mention that as tick functions don't work in a threaded
environment, you'll need to set up PHP as CGI if you're on Windows.

Dec 18 '05 #3
Mladen Gogala wrote:
I'm looking for a GPL licensed PHP profiler. The best thing around,
except the commercial goodies from NuSphere, seems to be Carl Taylor's
toolkit at http://www.adepteo.net/profiler/index.php
Any experiences? Does anybody here uses profiler to see where the
application time is spent and which components need fine tuning?


Never tried. But, I use APD <http://in.php.net/apd>. It's neat, but
lacks GUI. We use our own GUI (can't give, sorry).

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Dec 20 '05 #4
Chung Leong wrote:
Here is a simple profiler I wrote.

<snip>

Hard core programmers like you'll always write codes and would
restrain to use other tools:( But, I would suggest you to try APD
<http://in.php.net/apd> and see the difference.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Dec 20 '05 #5
On Mon, 19 Dec 2005 20:51:10 -0800, R. Rajesh Jeba Anbiah wrote:
Never tried. But, I use APD <http://in.php.net/apd>. It's neat, but
lacks GUI. We use our own GUI (can't give, sorry).


APD is a debugger, not a profiler. Thanks.

--
http://www.mgogala.com

Dec 20 '05 #6
On Tue, 20 Dec 2005 15:55:50 GMT, Mladen Gogala <go****@sbcglobal.net> wrote:
On Mon, 19 Dec 2005 20:51:10 -0800, R. Rajesh Jeba Anbiah wrote:
Never tried. But, I use APD <http://in.php.net/apd>. It's neat, but
lacks GUI. We use our own GUI (can't give, sorry).


APD is a debugger, not a profiler. Thanks.


"APD is the Advanced PHP Debugger. It was written to provide profiling and
debugging capabilities for PHP code"

And it goes on with an example of profiling later on the page.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Dec 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeff Mair | last post by:
Hello all, I haven't been using profiler for a terribly long time, and I've come across something that I just can't figure out. I'm running MS Virtual PC to run a Win2K Server OS with SQL...
8
by: patrickshroads | last post by:
I am running a profiler trace against a database and noticed that the reads column always shows 0. When running the same trace against another machine I get back values in the reads column. I took...
0
by: DraguVaso | last post by:
Hi, I'm using for a while DevPartner Profiler (http://www.compuware.com/products/devpartner/resources/profiler/profiler.as p), but unfortunately it works only for 2002 and 2003. Is there a...
9
by: Franco Gustavo | last post by:
Hi, All What's is the best .net profiler for Debug an application. I have to buy one but I don't know which one!! I tried some of them like Borland and AQTime. My big problem is, my...
3
by: Maansi Gupta | last post by:
Platform - Windows 2000 Professional , VC .NET 7.1 Hello, I have recently ported my source code from Visual Studio 6.0 to .NET 7.1 Previously with Visual Studio 6.0 I was using the profiler...
8
by: Bryan | last post by:
Does anyone have an example of an application that can connect to a running process and capture Trace.WriteLine calls like in SQL Server Profiler? I know that we can inherit from a TraceListener...
1
by: ofirmgr | last post by:
im trying to understand how the profiler works. so i started 2 profilers,one listen to another and I saw the profiler is running: exec sp_trace_create @P1 output, 1, NULL, NULL, NULL which means...
3
by: Sam Samson | last post by:
Can any-one recommend some good sites detailing how to code a simple memory profiler? How do they "look under the hood"? I built an uber simple service that tracks the process' memory but I need...
2
by: Paul Ritchie | last post by:
A few years ago I used a Profiler (I forget the name) on my Delphi code at the time and got fantastic results showing both: a) lines of code that took the longest to execute and b) lines of code...
0
by: anweshadash | last post by:
Using SQL Profiler: (Ref: http://msdn2.microsoft.com/en-us/library/ms181091.aspx) Sometimes it’s very beneficial to use sql profiler. Let’s have an idea about that and how to use that by...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.