Рубрики
Uncategorized

Использование PHP xhprof

Автор оригинала: David Wong.

Анализ производительности xhprof PHP

1. Clone xhprof-это стороннее расширение GitHub ( php office не поддерживает PHP 7)

https://github.com/longxinH/xhprof

2. Каталог расширений может быть расширен в виде расширенного исходного кода

phpize && ./configure && make && make install

3. Отредактируйте php.ini, чтобы включить расширение xhprof

[xhprof]
extension = xhprof.so
Xhprof.output_dir=/tmp/xhprof; performance analysis data file storage location requires PHP users to have writable and readable rights

4. Добавьте код в файл ввода проекта

xhprof_enable(XHPROF_FLAGS_NO_BUILTINS +
              XHPROF_FLAGS_CPU +
              XHPROF_FLAGS_MEMORY);
register_shutdown_function(function (){
        $data = xhprof_disable();   
        // xhprof_lib is in the folder after the first git clone step 
        include '/mnt/d/www/xhprof/xhprof_lib/utils/xhprof_lib.php';
        include '/mnt/d/www/xhprof/xhprof_lib/utils/xhprof_runs.php';
        $objXhprofRun = new XHProfRuns_Default();
        $objXhprofRun - > save_run ($data, "table"); // Generate data file suffix
    });

5. nginx или Apache создают каталоги загрузки сети (пример apache)


    ServerName xhprof.com
    ## xhprof/xhprof_html in the folder after the first git clone
    DocumentRoot "/mnt/d/www/xhprof/xhprof_html"
    DirectoryIndex index.html index.php index.html
    
         Options Indexes FollowSymLinks
         AllowOverride All
         Require all granted
    
 

6. Посещение http://xhprof.com/(локальное имя конфигурации виртуального хоста выше требует хоста), чтобы показать, что файл данных анализа производительности, созданный при каждом запуске программы, можно открыть, щелкнув

7. Если вы хотите просмотреть диаграмму производительности, нажмите Просмотреть полный график вызовов (серверу необходимо установить библиотеку graphviz).

Ubuntu installation method (pro apt-get install graphviz)

8. Отображение карт эффектов