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

前端 未结 12 734
无人共我
无人共我 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:42

    I use a combination of PEAR Benchmark and log4php.

    At the top of scripts I want to profile I create an object that wraps around a Benchmark_Timer object. Throughout the code, I add in $object->setMarker("name");calls, especially around suspect code.

    The wrapper class has a destroy method that takes the logging information and writes it to log4php. I typically send this to syslog (many servers, aggregates to one log file on one server).

    In debug, I can watch the log files and see where I need to improve things. Later on in production, I can parse the log files and do performance analysis.

    It's not xdebug, but it's always on and gives me the ability to compare any two executions of the code.

提交回复
热议问题