0

How do I use the Debugger to optimize my code? I'm using too much memory, my understanding is that the debugger has built in tools which help with optimizing code?

1 Answer 1

1

XDebug, among other things, allows you to profile your code, saving the profiling information to a file, which can be opened by analyzer programs, that can visualize how the control flow went, and how much time was spent in each function.

It helps you find bottlenecks, or slow parts in your code, but it won't directly optimise your code, you have to look at the data, and determine for yourself which parts to refactor.

You can enable the profiler by adding these settings to your php.ini:

xdebug.profiler_enable=1
xdebug.profiler_output_dir=c:\temp\

The documentation about the profiling feature of XDebug can be found on the official page.

Sign up to request clarification or add additional context in comments.

2 Comments

kcachegrind is one analyzer program
The PDT extension from Eclipse contains Xdebug, and Kcachegrind (seperate) can be used to analyze/visualize the data it creates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.