driceman/xhprof

XHProf: PHP7的层次化分析器

这个包的官方仓库似乎已经不存在,因此该包已被冻结。

dev-master 2019-12-12 07:33 UTC

This package is auto-updated.

Last update: 2024-08-12 18:02:26 UTC


README

Build Status

XHProf是一个针对PHP的函数级层次化分析器,具有基于HTML的简单导航界面。原始数据收集组件是用C语言(作为PHP扩展)实现的。报告/用户界面层全部用PHP编写。它能够报告每个函数的函数级包含和排除墙时、内存使用、CPU时间和调用次数。此外,它还支持比较两个运行(层次化DIFF报告)或聚合多个运行的结果。

本版本支持PHP7

PHP版本

  • 7.0
  • 7.1
  • 7.2
  • 7.3

安装

git clone https://github.com/longxinH/xhprof.git ./xhprof
cd xhprof/extension/
/path/to/php7/bin/phpize
./configure --with-php-config=/path/to/php7/bin/php-config
make && sudo make install

将配置添加到您的php.ini文件中

[xhprof]
extension = xhprof.so
xhprof.output_dir = /tmp/xhprof

php.ini配置

开启额外收集

PDO::exec

PDO::query

mysqli_query

$mysqli = new mysqli("localhost", "my_user", "my_password", "user");
$result = $mysqli->query("SELECT * FROM user LIMIT 10");
输出数据
mysqli::query#SELECT * FROM user LIMIT 10

PDO::prepare

将预处理占位符转换为实际参数,更直观的分析性能(不改变zend执行过程)

$_sth = $db->prepare("SELECT * FROM user where userid = :id and username = :name");
$_sth->execute([':id' => '1', ':name' => 'admin']);
$data1 = $_sth->fetch();

$_sth = $db->prepare("SELECT * FROM user where userid = ?");
$_sth->execute([1]);
$data2 = $_sth->fetch();
输出数据
PDOStatement::execute#SELECT * FROM user where userid = 1 and username = admin
PDOStatement::execute#SELECT * FROM user where userid = 1

Curl

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.baidu.com");
$output = curl_exec($ch);
curl_close($ch);
输出数据
curl_exec#http://www.baidu.com

PECL仓库

pecl