= phptop = [[PageOutline]] == Summary == '''Licence''': [http://www.gnu.org/licenses/gpl.html GPL v3] [[BR]] '''Source''': * Download attachment:phptop-0.1.tar.gz * Checkout with {{{svn co svn://forge.bearstech.com/forge/phptop}}} * Browse at source:/phptop/ '''phptop''' prints per query and average metrics comparable to the 'time' program or shell builtin: wallclock, user and system CPU time along with memory and other ressource usages. It uses a a few lines of PHP with hook into your existing code without any changes, record per query statistics via the standar error log, then collect and print reports with a standalone program. '''phptop''' itself is written in Perl and requires [http://search.cpan.org/~gaas/libwww-perl-5.833/ LWP]. == Installation == It can be easily globally activated on a LAMP server and requires little ressources and a single line configuration change in your php.ini. For instance: {{{ server:~# echo auto_prepend_file=/path/to/phptop_hook.php >/etc/php/php.ini server:~# apache2ctl reload }}} Wait a few minutes to collect enough data then run '''phptop'''. == Usage == On a server with several distinct vhost and applications, anlyzing last 15 minutes and sorting by average memory usage per query: {{{ server:~$ phptop -t 15 -s mem Hit Time User Sys Mem/hit Mem_max Inc/hit Inc_max http://foo.org/node/88 5 0.3 0.2 0.0 4.3 21.5 15 78 http://bar.org/sv/cities 5 1.2 0.2 0.1 4.9 24.5 25 125 http://foo.org/homepage/feed 15 0.7 0.5 0.1 4.2 21.2 14 74 http://bip.net/2007/08/24/ 5 0.6 0.2 0.0 2.9 14.2 14 71 http://bip.net/feed/atom/ 5 0.1 0.1 0.0 2.8 14.0 11 58 http://baz.com/tag/megaloop/ 5 0.2 0.1 0.0 2.4 12.0 11 56 http://bip.net/ 10 0.7 0.4 0.1 2.9 14.2 14 70 http://baz.com/spots/ 5 1.2 0.0 0.0 1.6 7.8 16 84 http://baz.com/tag/international/ 5 0.2 0.1 0.0 2.4 11.8 11 56 http://baz.com/ 10 0.4 0.3 0.1 2.4 12.0 11 56 Total 140 6.4 2.6 0.5 }}} Once the 'recorder hook' is installed, running '''phptop''' does not need other privileges besides read access to the relevant log files.