facebook twitter hatena line email

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

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(ページの作成:「==インストール(php8の場合)== <pre> dnf install -y php-devel php-pear gcc make pecl install tideways_xhprof </pre> ===php.ini設定== <pre> echo "extension=xhpro...」)
 
(サンプル)
 
(同じ利用者による、間の3版が非表示)
行5: 行5:
 
</pre>
 
</pre>
  
===php.ini設定==
+
===php.ini設定===
 
<pre>
 
<pre>
 
echo "extension=xhprof.so" > /etc/php.d/50-xhprof.ini
 
echo "extension=xhprof.so" > /etc/php.d/50-xhprof.ini
行15: 行15:
 
xhprof
 
xhprof
 
</pre>
 
</pre>
 +
 +
==サンプル==
 +
<pre>
 +
<?php
 +
xhprof_enable();
 +
 +
// 適当な処理
 +
usleep(100000);
 +
 +
$data = xhprof_disable();
 +
var_dump($data);
 +
</pre>
 +
 +
出力
 +
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) } }

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) } }