Skip to content

Instantly share code, notes, and snippets.

@dhrrgn
Last active February 4, 2021 21:28
Show Gist options
  • Save dhrrgn/7662774 to your computer and use it in GitHub Desktop.
Save dhrrgn/7662774 to your computer and use it in GitHub Desktop.
Profiling your PHP Application

XDebug Profiling

XDebug Config

xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "/path/to/folder/for/cachegrind/files"
xdebug.profiler_output_name = "callgrind.out.%t.%p"

Install QCacheGrind (for OSX Mavericks)

Note: This requires Homebrew be installed. See http://brew.sh/ for instructions.

  1. Install QT (this will take a while)

     brew install qt --HEAD
    
  2. Install QCacheGrind

     brew install qcachegrind
    
  3. Create a Symlink in your Applications folder.

     brew linkapps
    
  4. Install Graphviz (for producing call graphs)

     brew install graphviz
     sudo ln -s /usr/local/bin/dot /usr/bin/dot
    

You should be all setup. Now, visit the application in the browser, and it should create files in the path you specified in the XDebug config. Open the QCacheGrind.app application and open one of the files.

@Arhimandril
Copy link

Webgrind is also a solid option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment