установка xhprof

    установка xhprof
    yum install php-pecl-xhprof.x86_64 xhprof.noarch

    создаем файл /etc/php.d/00_xhprof.ini:
    auto_prepend_file = /var/www/inc/prepend.php
    auto_append_file = /var/www/inc/append.php



    релоадим php-fpm:
    service php-fpm reload

    в папке с вашим сайтом:
    ln -s /usr/share/xhprof/xhprof_html xhprof_html
    ln -s /usr/share/xhprof/xhprof_lib xhprof_lib

    создаем файлы со следующим содержимым:

    /var/www/inc/append.php:

    ======= cut =======
    <?php

    if(XHPROF_ENABLED) {
    $id='general';
    $type='none';
    $xhprof_data = xhprof_disable();

    include_once "/usr/share/xhprof/xhprof_lib/utils/xhprof_lib.php";
    include_once "/usr/share/xhprof/xhprof_lib/utils/xhprof_runs.php";

    // save raw data for this profiler run using default
    // implementation of iXHProfRuns.
    $xhprof_runs = new XHProfRuns_Default();

    $ns = "xhprof_$type";
    // save the run under a namespace "xhprof_foo"
    $run_id = $xhprof_runs->save_run($xhprof_data,$ns);

    $url = "/xhprof_html/index.php?run=$run_id&source=$ns";
    echo "<a href='$url' target='_xhprof_$id'>Profile available here: $url</a><br/>\n";
    echo "$run_id<br/>\n";
    }

    ======= cut =======

    /var/www/inc/prepend.php:
    ======= cut =======
    <?php

    define('XHPROF_ENABLED',false);

    if(XHPROF_ENABLED) {
    xhprof_enable(XHPROF_FLAGS_MEMORY | XHPROF_FLAGS_CPU);
    }
    ======= cut =======