facebook twitter hatena line email

「Php/速度改善/tideways xhprof」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
行17: 行17:
  
 
==サンプル==
 
==サンプル==
</pre>
+
<pre>
 
<?php
 
<?php
 
xhprof_enable();
 
xhprof_enable();
行26: 行26:
 
$data = xhprof_disable();
 
$data = xhprof_disable();
 
var_dump($data); // array(3) { ["main()==>usleep"]=> array(2) { ["ct"]=> int(1) ["wt"]=> int(100109) } ["main()==>xhprof_disable"]=> array(2) { ["ct"]=> int(1) ["wt"]=> int(0) } ["main()"]=> array(2) { ["ct"]=> int(1) ["wt"]=> int(100125) } }
 
var_dump($data); // array(3) { ["main()==>usleep"]=> array(2) { ["ct"]=> int(1) ["wt"]=> int(100109) } ["main()==>xhprof_disable"]=> array(2) { ["ct"]=> int(1) ["wt"]=> int(0) } ["main()"]=> array(2) { ["ct"]=> int(1) ["wt"]=> int(100125) } }
<pre>
+
</pre>

2026年4月17日 (金) 04:32時点における版

インストール(php8の場合)

dnf install -y php-devel php-pear gcc make
pecl install tideways_xhprof

php.ini設定

echo "extension=xhprof.so" > /etc/php.d/50-xhprof.ini

確認

$ php -m | grep xhprof
xhprof

サンプル

<?php
xhprof_enable();

// 適当な処理
usleep(100000);

$data = xhprof_disable();
var_dump($data); // array(3) { ["main()==>usleep"]=> array(2) { ["ct"]=> int(1) ["wt"]=> int(100109) } ["main()==>xhprof_disable"]=> array(2) { ["ct"]=> int(1) ["wt"]=> int(0) } ["main()"]=> array(2) { ["ct"]=> int(1) ["wt"]=> int(100125) } }