Phptop: Simple PHP ressource profiler, safe and useful for production sites
Published on: 2025-06-11 19:52:56
phptop (c) 2009-2024 Bearstech - https://bearstech.com/
phptop prints per query and average metrics comparable to 'time' (wallclock, user and system CPU time) along with memory and other ressource usages.
It can be easily globally activated on a LAMP server and requires little ressources and a single line configuration change in your php.ini. It has been used by Bearstech on many production servers for years without any problems.
Requires PHP >= 5.2.0. Tested up to PHP 8.2.
Example usage:
server:~# echo auto_prepend_file=/path/to/phptop_hook.php >>path/to/php.ini (or .user.ini) server:~# apache2ctl reload (or php-fpm reload)
(Wait at least a few minutes to collect data...)
server:~# phptop -s mem URL Hit Time User Sys >Mem/hit Mem_max http://blog.dummy.com/facebook/myapi/ 5 0.8 0.5 0.1 6.2 31.0 http://blog.dummy.com/feed 10 1.0 0.8 0.1 6.0 30.2 http://blog.dummy.com/feed/ 10 1.2 1.0 0.0 6.0 30.2 http://blog.dummy.com/tag/peekk/ 5 0.6 0.5 0.0 6.2 30.8 http://blog.dummy.com/2008/0
... Read full article.