zoukankan      html  css  js  c++  java
  • php性能分析工具xhprof

    安装方法:

    wget http://pecl.php.net/get/xhprof-0.9.x.tgz

    cp xhprof-0.9.x.tgz /home/www/xhprof.tgz

    tar zxvf /home/www/xhprof.tgz

    cd xhprof/extension

    phpize

    ./configure --enable-xhprof --with-php-config=/usr/bin/php-config

    make && make install

    vim /etc/php.ini

    [xhprof]
    extension=xhprof.so
    ;下面的这个地址是用来保存测量记录的目录,在页面输出测量得到的数据的时候,它会自动到这儿来找输出的文件。
    xhprof.output_dir=/tmp

     service php-fpm restart

    ok!

    使用方法:

    <?php
    //来自xhprof的例子
    function bar($x) {
      if ($x > 0) {
        bar($x - 1);
      }
    }
    
    
    // 在代码开头加上
    xhprof_enable();
    // xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);这个还可以分析cpu和内存使用情况
    // 你的程序
    foo();
    
    // 在代码结尾加上
    $xhprof_data = xhprof_disable();
    
    // xhprof的数据
    print_r($xhprof_data);
    
    
    //这里是xhprof的地址,echo出来直接复制地址访问可以查看报告
    $XHPROF_ROOT = realpath(dirname(__FILE__) .'/..');
    include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
    include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
    
    // save raw data for this profiler run using default
    // implementation of iXHProfRuns.
    $xhprof_runs = new XHProfRuns_Default();
    
    // save the run under a namespace "xhprof_foo"
    $run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo");
    
    echo "---------------
    ".
         "Assuming you have set up the http based UI for 
    ".
         "XHProf at some address, you can view run at 
    ".
         "http://<xhprof-ui-address>/index.php?run=$run_id&source=xhprof_foo
    ".
         "---------------
    ";
  • 相关阅读:
    Hbase多master
    hbase 新增节点
    HBase优化
    hbase 各个概念,region,storefile
    HBase简介(很好的梳理资料)
    hbase blocksize设置,与hdfs关系
    hbase常用运维命令
    hbase很有价值的读写性能提升
    关于hbase的read操作的深入研究 region到storefile过程
    Storm 实现滑动窗口计数和TopN排序
  • 原文地址:https://www.cnblogs.com/trying/p/3553161.html
Copyright © 2011-2022 走看看