• 首页
  • css3教程
  • html5教程
  • jQuery手册
  • php7教程
  • MySQL手册
  • apache手册
  • 位置: php7教程 -> PECL扩展库

    APD(PHP高级调试程序)

    这些函数的行为受php.ini中的设置影响。

    APD 配置选项
    名字默认可修改范围更新日志
    apd.dumpdirNULLPHP_INI_ALL
    apd.statement_tracing"0"PHP_INI_ALL

    要在Windows下构建APD,您需要在http://php.net/上描述的一个工作PHP编译环境——基本上,它要求您拥有微软Visual C++、WIN32 Buudi.Zip、BISO/Flex,以及一些知道如何使其工作。还确保adp.dsp具有DOS行结束;如果它具有UNIX行结束,微软Visual C++将对此抱怨。

    How to use PHP-APD in your scripts

    1. As the first line of your PHP script, call the apd_set_pprof_trace() function to start the trace:

      <?php
      apd_set_pprof_trace();
      ?>
      

      You can insert the line anywhere in your script, but if you do not start tracing at the beginning of your script you discard profile data that might otherwise lead you to a performance bottleneck.

    2. Now run your script. The dump output will be written toapd.dumpdir/pprof_pid.ext. Tip

      If you're running the CGI version of PHP, you will need to add the '-e' flag to enable extended information for apd to work properly. For example: php -e -f script.php

    3. To display formatted profile data, issue the pprofp command with the sort and display options of your choice. The formatted output will look something like:

      bash-2.05b$ pprofp -R /tmp/pprof.22141.0
      Trace for /home/dan/testapd.php
      Total Elapsed Time = 0.00
      Total System Time  = 0.00
      Total User Time    = 0.00
      Real         User        System             secs/    cumm
      %Time (excl/cumm)  (excl/cumm)  (excl/cumm) Calls    call    s/call  Memory Usage Name
      --------------------------------------------------------------------------------------
      100.0 0.00 0.00  0.00 0.00  0.00 0.00     1  0.0000   0.0009            0 main
      56.9 0.00 0.00  0.00 0.00  0.00 0.00     1  0.0005   0.0005            0 apd_set_pprof_trace
      28.0 0.00 0.00  0.00 0.00  0.00 0.00    10  0.0000   0.0000            0 preg_replace
      14.3 0.00 0.00  0.00 0.00  0.00 0.00    10  0.0000   0.0000            0 str_replace
      

      The -R option used in this example sorts the profile table by the amount of real time the script spent executing a given function. The "cumm call" column reveals how many times each function was called, and the "s/call" column reveals how many seconds each call to the function required, on average.

    4. To generate a calltree file that you can import into the KCacheGrind profile analysis application, issue the pprof2calltree comand.