我已经在我的 PC(Windows 10)上安装了 Apache 2.4 和 PHP 5.6。
启用 Xdebug 后,PHP 的运行速度比没有 Xdebug 时慢 10 倍(!)。
这是php.ini
配置:
zend_extension = "php_xdebug-2.3.3-5.6-vc11-x86_64.dll"
xdebug.remote_autostart = 0
xdebug.profiler_enable = 0
xdebug.profiler_output_dir = "C:\PHP\tmp"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_mode=req
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port=9000
xdebug.idekey=netbeans-xdebug
xdebug.trace_output_dir = "C:\PHP\tmp"
xdebug.auto_trace = 0
xdebug.var_display_max_depth = 3
xdebug.remote_connect_back = 0
我已确保禁用分析器和自动启动。 有谁知道这种行为的原因是什么?
最佳答案
来源:https://www.phase2technology.com/blog/profiling-production-whats-slowing-you-down
Instrumentation in interpreted languages, like PHP and Javascript, involves hooking into the runtime and explicitly collecting information about every function call as is occurs. This allows you to view the elapsed time spent, a call graph of function calls in the stack, memory and CPU stats, and other system data about your code as it executes on each request. Instrumented profiling does add overhead however, and it can be significant; this depends on the complexity of your application. This makes instrumented profiling ideal for development and debugging sessions, but limited for ongoing production analysis and monitoring.
检测的一个很好的替代方法是基于样本的分析。
Sample-based profiling involves taking snapshots of an application at fixed intervals. Each snapshot records the currently-executed function(s), and the aggregate of these snapshots is used to approximate when and where time is being spent in your code. This provides much less detail than instrumented profiling but without the significant added overhead, making it ideal for production use.
看sample_prof有关使用 PHP 进行基于样本的分析的示例。
关于php - 启用 Xdebug 后,PHP 运行速度异常缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31882554/