Find out where your PHP code is slowing down (Performance Issue)

前端 未结 12 732
无人共我
无人共我 2020-12-04 18:25

Here\'s my first question at SO.

I have a internal application for my company which I\'ve been recently ask to maintain. The applications is built in PHP and its fai

12条回答
  •  佛祖请我去吃肉
    2020-12-04 18:37

    Also You could use APD (Advanced PHP Debugger).

    It's quite easy to make it work.

    $ php apd-test.php
    
    $ pprofp -l pprof.SOME_PID
    
    Trace for /Users/martin/develop/php/apd-test/apd-test.php
    Total Elapsed Time = 0.12
    Total System Time  = 0.01
    Total User Time    = 0.07
    
    
             Real         User        System             secs/    cumm
    %Time (excl/cumm)  (excl/cumm)  (excl/cumm) Calls    call    s/call  Memory Usage Name
    --------------------------------------------------------------------------------------
    71.3 0.06 0.06  0.05 0.05  0.01 0.01  10000  0.0000   0.0000            0 in_array
    27.3 0.02 0.09  0.02 0.07  0.00 0.01  10000  0.0000   0.0000            0 my_test_function
     1.5 0.03 0.03  0.00 0.00  0.00 0.00      1  0.0000   0.0000            0 apd_set_pprof_trace
     0.0 0.00 0.12  0.00 0.07  0.00 0.01      1  0.0000   0.0000            0 main
    

    There is a nice tutorial how to compile APD and make profiling with it : http://martinsikora.com/compiling-apd-for-php-54

提交回复
热议问题