www:~> cd /usr/local/lib/php
www:/usr/local/lib/php> ln -s extensions/no-debug-non-zts-20020429/apd.so apd.so
Then in your php.ini file:
zend_extension = "/usr/local/lib/php/apd.so"
apd.dumpdir = /tmp
It isn't completely transparent. You need to tell the profiler
when to start profiling. At the top of a script you want to profile, add this call:
<?php
apd_set_pprof_trace();
?>
The use the command-line tool called pprofp:
wwww: ~> pprofp
pprofp <flags> <trace file>
Sort options
-a Sort by alphabetic names of subroutines.
-l Sort by number of calls to subroutines
-m Sort by memory used in a function call.
-r Sort by real time spent in subroutines.
-R Sort by real time spent in subroutines (inclusive of child calls).
-s Sort by system time spent in subroutines.
-S Sort by system time spent in subroutines (inclusive of child calls).
-u Sort by user time spent in subroutines.
-U Sort by user time spent in subroutines (inclusive of child calls).
-v Sort by average amount of time spent in subroutines.
-z Sort by user+system time spent in subroutines. (default)
Display options
-c Display Real time elapsed alongside call tree.
-i Suppress reporting for php builtin functions
-O <cnt> Specifies maximum number of subroutines to display. (default 15)
-t Display compressed call tree.
-T Display uncompressed call tree.
% ls -latr /tmp/pprofp.*
-rw-r--r-- 1 nobody nobody 16692 Dec 3 01:19 /tmp/pprof.04545
% pprofp -z /tmp/pprof.04545
Trace for /home/rasmus/phpweb/bm.php
Total Elapsed Time = 0.01
Total System Time = 0.00
Total User Time = 0.01
Real User System secs/ cumm
%Time (excl/cumm) (excl/cumm) (excl/cumm) Calls call s/call Memory Usage Name
--------------------------------------------------------------------------------------
100.0 0.01 0.01 0.01 0.01 0.00 0.00 2 0.0050 0.0050 3488 include
0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.0000 48 c
0.0 0.00 0.00 0.00 0.00 0.00 0.00 21 0.0000 0.0000 1168 b
0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.0000 56 a
0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.0000 0 main
0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.0000 1080 range
Trace for /home/rasmus/phpweb/index.php
Total Elapsed Time = 0.69
Total System Time = 0.01
Total User Time = 0.08
Real User System secs/ cumm
%Time (excl/cumm) (excl/cumm) (excl/cumm) Calls call s/call Memory Usage Name
--------------------------------------------------------------------------------------
33.3 0.11 0.13 0.02 0.03 0.01 0.01 7 0.0043 0.0057 298336 require_once
22.2 0.02 0.02 0.02 0.02 0.00 0.00 183 0.0001 0.0001 -33944 feof
11.1 0.01 0.01 0.01 0.01 0.00 0.00 3 0.0033 0.0033 -14808 define
11.1 0.04 0.04 0.01 0.01 0.00 0.00 182 0.0001 0.0001 112040 fgetcsv
11.1 0.25 0.25 0.01 0.01 0.00 0.00 6 0.0017 0.0017 3768 getimagesize
11.1 0.01 0.01 0.01 0.01 0.00 0.00 55 0.0002 0.0002 2568 sprintf
0.0 0.00 0.00 0.00 0.00 0.00 0.00 7 0.0000 0.0000 -136 printf
0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.0000 136 htmlspecialchars
0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.0000 -16 mirror_provider_url
0.0 0.00 0.00 0.00 0.00 0.00 0.00 7 0.0000 0.0000 112 spacer
0.0 0.00 0.00 0.00 0.00 0.00 0.00 10 0.0000 0.0000 -552 delim
0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.0000 112 mirror_provider
0.0 0.00 0.00 0.00 0.00 0.00 0.00 20 0.0000 0.0000 -624 print_link
0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.0000 24 have_stats
0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.0000 -72 make_submit
0.0 0.00 0.00 0.00 0.00 0.00 0.00 2 0.0000 0.0000 112 strrchr
0.0 0.08 0.08 0.00 0.00 0.00 0.00 2 0.0000 0.0000 168 filesize
0.0 0.00 0.00 0.00 0.00 0.00 0.00 1 0.0000 0.0000 -16 commonfooter
0.0 0.00 0.11 0.00 0.00 0.00 0.00 2 0.0000 0.0000 0 download_link
0.0 0.00 0.25 0.00 0.01 0.00 0.00 6 0.0000 0.0017 208 make_image