2004-08-05 13:15:18 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2005-09-04 11:49:43 +00:00
|
|
|
<!-- $Revision: 1.5 $ -->
|
|
|
|
<!-- Purpose: basic.php -->
|
|
|
|
<!-- Membership: pecl -->
|
|
|
|
|
2004-08-05 13:15:18 +00:00
|
|
|
<reference id="ref.apd">
|
|
|
|
<title>Advanced PHP debugger</title>
|
|
|
|
<titleabbrev>APD</titleabbrev>
|
|
|
|
<partintro>
|
|
|
|
|
|
|
|
<section id="apd.intro">
|
|
|
|
&reftitle.intro;
|
|
|
|
<para>
|
2004-09-28 04:35:03 +00:00
|
|
|
APD is the Advanced PHP Debugger. It was written to provide profiling and
|
|
|
|
debugging capabilities for PHP code, as well as to provide the ability to
|
|
|
|
print out a full stack backtrace. APD supports interactive debugging, but
|
|
|
|
by default it writes data to trace files. It also offers event based
|
|
|
|
logging so that varying levels of information (including function calls,
|
|
|
|
arguments passed, timings, etc.) can be turned on or off for individual
|
|
|
|
scripts.
|
|
|
|
<caution>
|
2004-08-05 13:15:18 +00:00
|
|
|
<para>
|
|
|
|
APD is a Zend Extension, modifying the way the internals of PHP handle
|
|
|
|
function calls, and thus may or may not be compatible with other Zend
|
|
|
|
Extensions (for example Zend Optimizer).
|
|
|
|
</para>
|
2004-09-28 04:35:03 +00:00
|
|
|
</caution>
|
|
|
|
</para>
|
2004-08-05 13:15:18 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
&reference.apd.configure;
|
|
|
|
|
2004-09-28 04:35:03 +00:00
|
|
|
&reference.apd.ini;
|
2004-08-05 13:15:18 +00:00
|
|
|
|
2004-09-28 04:35:03 +00:00
|
|
|
<section id="apd.resources">
|
|
|
|
&reftitle.resources;
|
|
|
|
&no.resource;
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="apd.constants">
|
|
|
|
&reftitle.constants;
|
|
|
|
&no.constants;
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="apd.examples">
|
2004-08-05 13:15:18 +00:00
|
|
|
<title>How to use PHP-APD in your scripts</title>
|
2004-09-28 04:35:03 +00:00
|
|
|
<procedure>
|
|
|
|
<step>
|
2004-08-05 13:15:18 +00:00
|
|
|
<para>
|
2004-09-28 04:35:03 +00:00
|
|
|
As the first line of your PHP script, call the apd_set_pprof_trace() function
|
|
|
|
to start the trace:
|
2004-08-05 13:15:18 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
2004-09-25 15:15:12 +00:00
|
|
|
apd_set_pprof_trace();
|
2004-08-05 13:15:18 +00:00
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
<para>
|
2004-09-28 04:35:03 +00:00
|
|
|
You can insert the line anywhere in your script, but if you do not start
|
|
|
|
tracing at the beginning of your script you discard profile data that might
|
|
|
|
otherwise lead you to a performance bottleneck.
|
2004-08-05 13:15:18 +00:00
|
|
|
</para>
|
2004-09-28 04:35:03 +00:00
|
|
|
</step>
|
|
|
|
<step>
|
2004-08-05 13:15:18 +00:00
|
|
|
<para>
|
2004-09-28 04:35:03 +00:00
|
|
|
Now run your script. The dump output will be written to
|
|
|
|
<filename>apd.dumpdir/pprof_pid.ext</filename>.
|
|
|
|
<tip>
|
|
|
|
<para>
|
|
|
|
If you're running the CGI version of PHP, you will need to add the '-e'
|
|
|
|
flag to enable extended information for apd to work properly. For
|
|
|
|
example:
|
|
|
|
<userinput>php -e -f script.php</userinput>
|
|
|
|
</para>
|
|
|
|
</tip>
|
2004-08-05 13:15:18 +00:00
|
|
|
</para>
|
2004-09-28 04:35:03 +00:00
|
|
|
|
|
|
|
</step>
|
|
|
|
<step>
|
2004-08-05 13:15:18 +00:00
|
|
|
<para>
|
2004-09-28 04:35:03 +00:00
|
|
|
To display formatted profile data, issue the <command>pprofp</command>
|
|
|
|
command with the sort and display options of your choice. The formatted
|
|
|
|
output will look something like:
|
2004-08-05 13:15:18 +00:00
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
2004-09-28 04:35:03 +00:00
|
|
|
bash-2.05b$ pprofp -R /tmp/pprof.22141.0
|
|
|
|
|
|
|
|
Trace for /home/dan/testapd.php
|
|
|
|
Total Elapsed Time = 0.00
|
|
|
|
Total System Time = 0.00
|
|
|
|
Total User Time = 0.00
|
|
|
|
|
2004-08-05 13:15:18 +00:00
|
|
|
|
2004-09-28 04:35:03 +00:00
|
|
|
Real User System secs/ cumm
|
|
|
|
%Time (excl/cumm) (excl/cumm) (excl/cumm) Calls call s/call Memory Usage Name
|
|
|
|
--------------------------------------------------------------------------------------
|
|
|
|
100.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.0009 0 main
|
|
|
|
56.9 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0005 0.0005 0 apd_set_pprof_trace
|
|
|
|
28.0 0.00 0.00 0.00 0.00 0.00 0.00 10 0.0000 0.0000 0 preg_replace
|
|
|
|
14.3 0.00 0.00 0.00 0.00 0.00 0.00 10 0.0000 0.0000 0 str_replace
|
2004-08-05 13:15:18 +00:00
|
|
|
]]>
|
|
|
|
</screen>
|
|
|
|
</para>
|
2004-09-28 04:35:03 +00:00
|
|
|
<para>
|
|
|
|
The -R option used in this example sorts the profile table by the amount
|
|
|
|
of real time the script spent executing a given function. The "cumm call"
|
|
|
|
column reveals how many times each function was called, and the "s/call"
|
|
|
|
column reveals how many seconds each call to the function required, on
|
|
|
|
average.
|
|
|
|
</para>
|
|
|
|
</step>
|
|
|
|
<step>
|
|
|
|
<para>
|
|
|
|
To generate a calltree file that you can import into the KCacheGrind
|
|
|
|
profile analysis application, issue the <command>pprof2calltree</command>
|
|
|
|
comand.
|
|
|
|
</para>
|
|
|
|
</step>
|
|
|
|
</procedure>
|
2004-08-05 13:15:18 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section id="apd.contact">
|
2004-09-28 04:35:03 +00:00
|
|
|
<title>Contact information</title>
|
2004-08-05 13:15:18 +00:00
|
|
|
<para>
|
2004-08-13 01:00:48 +00:00
|
|
|
If you have comments, bugfixes, enhancements or want to help developing
|
2004-08-05 13:15:18 +00:00
|
|
|
this beast, you can send an mail to
|
|
|
|
<ulink url="mailto:&email.apd;">&email.apd;</ulink>. Any help is very
|
|
|
|
welcome.
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
</partintro>
|
|
|
|
|
|
|
|
&reference.apd.functions;
|
|
|
|
|
|
|
|
</reference>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|