標籤:http io ar color os 使用 for strong on
1.先把tgz的包在本地解壓,把裡面的tar包傳到 centos的/root目錄,使用tar -xvf 解壓tar包,解壓出了xdebug-2.2.4、package.xml,
2。進入xdebug,執行phpize
3.不報錯的話 執行./configure --enable-xdebug
4、make && make install
6.vi /etc/php.ini,後面加入
[Xdebug]
zend_extension ="/usr/lib/php/modules/xdebug.so"
xdebug.profiler_enable=on
xdebug.trace_output_dir="/tmp/xdebug"
xdebug.profiler_output_dir="/tmp/xdebug"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
7.建立log輸出目錄 mkdir -p /tmp/xdebug
8.給log輸出目錄賦許可權 chmod 777 /tmp/xdebug
9.重啟apache ,service httpd restart
10.訪問網站後,在/tmp/xdebug中會有日誌
11、使用wincachegrind查看日誌。
12、分析日誌:overall中 call:調用次數;self 方法自己的時間;cum 方法總時間,包括了調用其他方法的
安裝xhprof函數層級的效能分析()
1、1.先把tgz的包在本地解壓,把裡面的tar包傳到 centos的/root目錄,使用tar -xvf 解壓tar包,解壓出了xdebug-2.2.4、package.xml,
2。進入xhprof,再進入cd extension/,執行phpize
3、./configure --with-php-config=/usr/bin/php-config
4、make && make install
5.建立目錄 mkdir -p /tmp/xhprof
6.給l目錄賦許可權 chmod 777 /tmp/xhprof
7.vi /etc/php.ini,後面加入
[xhprof]
extension=xhprof.so
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
;xhprof.output_dir=<directory_for_storing_xhprof_runs>
xhprof.output_dir=/tmp/xhprof
8.重啟apache ,service httpd restart
9.在php檔案打點
// cpu:XHPROF_FLAGS_CPU 記憶體:XHPROF_FLAGS_MEMORY
// 如果兩個一起:XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
// 要測試的php代碼
foo();
$data = xhprof_disable(); //返回運行資料
// xhprof_lib在下載的包裡存在這個目錄,記得將目錄包含到啟動並執行php代碼中
include_once "xhprof_lib/utils/xhprof_lib.php";
include_once "xhprof_lib/utils/xhprof_runs.php";
$objXhprofRun = new XHProfRuns_Default();
// 第一個參數j是xhprof_disable()函數返回的運行資訊
// 第二個參數是自訂的命名空間字串(任一字元串),
// 返回運行ID,用這個ID查看相關的運行結果
$run_id = $objXhprofRun->save_run($data, "xhprof");
var_dump($run_id);
echo "\nhttp://192.168.0.99/xxx/xhprof_html/index.php?run={$run_id}&source=xhprof\n";
10、http://192.168.0.99/xhproftest/xhprof_html/index.php?run=54779d94bfa61&source=xhprof
查看統計報告
calls 調用次數
incl.wall time
excl.wall time自身時間
cpu毫秒
memuse位元組
peakmemuse 記憶體峰值
圖表中紅色為瓶頸、黃色為路徑和耗時。
MYSQL_general_log
mysql> show global variables like "%general%";
+------------------+----------------------------------+
| Variable_name | Value |
+------------------+----------------------------------+
| general_log | OFF |
| general_log_file | /opt/lampp/var/mysql/centos1.log |
+------------------+----------------------------------+
2 rows in set (0.00 sec)
mysql> set global general_log=ON;
Query OK, 0 rows affected (0.04 sec)
mysql> show global variables like "%general%";
+------------------+----------------------------------+
| Variable_name | Value |
+------------------+----------------------------------+
| general_log | ON |
| general_log_file | /opt/lampp/var/mysql/centos1.log |
+------------------+----------------------------------+
2 rows in set (0.04 sec)
用完了記得關掉
mysql> set global general_log=OFF;
Query OK, 0 rows affected (0.01 sec)
mysql> show global variables like ‘general%‘;
+------------------+----------------------------------+
| Variable_name | Value |
+------------------+----------------------------------+
| general_log | OFF |
| general_log_file | /opt/lampp/var/mysql/centos1.log |
+------------------+----------------------------------+
2 rows in set (0.00 sec)
搭建4.xdebug+mysql general_log