php Install xhprof extension (compatible with php5 and 7)
git clone [email protected]:longxinH/xhprof.git cd xhprof /usr/local/php7/bin/phpize ./configure --with-php-config=/usr/local/php7/bin/php-config make sudo make install
The extension is compiled, confirm it
ls /usr/local/php7/lib/php/extensions/no-debug-non-zts-20180731/xhprof.so
Put the prepend file in /tmp/xhprof.prepend .php under
vi /usr/local/php7/lib/php.ini [xhprof] extension=xhprof.so auto_prepend_file ="/tmp/xhprof.prepend.php";
Restart apache
ps: prepend file xhprof.prepend.php
2 && !empty($xhprof_data)) { array_unshift($xhprof_data, http_build_query($_REQUEST)); $xhprof_file = '/tmp/xhprof/' . date('YmdHis0000') . uniqid() . '.' . str_replace('.', '_', strtolower((isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'NOHOST') . '-' . (isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'NOMETHOD'))) . '.xhprof'; file_put_contents($xhprof_file, serialize($xhprof_data)); } });
The above is the detailed content of PHP performance analysis tool xhprof. For more information, please follow other related articles on the PHP Chinese website!