download on the mac app store

Treemap, Callgraph, Heatmap, Call tree, Print and PDF, Annotated sourcefile viewer. Combine multiple metrics into one chart. Suppress functions based on the source file path.

The new Xdebug 2.6 (and later) added support for memory profiling php scripts. Profiling Viewer already handles multiple types of costs. Just open the generated file and select between Time and Memory costs types.

show more...

Profiling PHP with Xdebug on Mac

See also:Installing Xdebug on MacOS High Sierra

First, install PHP on a development server. Then, install Xdebug. There is an installation manual at the Xdebug site.

After installing xdebug, the profiler is default off. To get it work, edit your php.ini as follows.

Check whether the xdebug extension will be loaded. Search for the line and add it if missing.

Check and set the paremeters

xdebug.auto_trace = 0
xdebug.profiler_aggregate = 0
xdebug.profiler_append = 0

; enable profiling by setting this to 1, setting it to 0 will disable it again
xdebug.profiler_enable = 1

; where to store the callgrind files
; this folder must be writeable by the webserver
xdebug.profiler_output_dir = /tmp

; suffix the filename with timestamp (microseconds)
; for example: callgrind_1179434749_642382.out
xdebug.profiler_output_name = callgrind_%u.out


Now start or restart your webserver to load the modifications

Open a the site you want to profile in a webbrowser. When everything went good, the php script will be profiled and the callgrind profiling output will be written to /tmp. The file name is something like "callgrind_1179434749_642382.out". With the above configuration you will get a separate callgrind file for every request.

To visualize the callgrind file on the Mac, open the "callgrind_*.out" files with Profiling Viewer and you will get treemaps, callgraphs, heatmaps and annotated source code (something like a code coverage). You can also print all the chars as PDF. Since Xdebug version 2.6 it is also possible to profile and analyze the memory usage of your PHP code.

Profiling Golang with pprof and callgrind

To profile go Programs, install the Go programming language, for example under /usr/local/go (this is the default installation path on MacOS)

There is a somewhat older tutorial about profiling go programs at This article points to a github repository with the sourcecodes used in the example:

I will use the file havlak2.go for this demo. You can download a copy for example here:

Create a new folder and download the havlak2.go file

#create the test folder in your home directory
mkdir ~/test
#chage into the testfolder
cd ~/test

#download the file havlak2.go
curl -o havlak2.go

#build the file
go build havlak2.go

#profile it with pprof and write the profiling data into
#this can take a few seconds...
./havlak2 -cpuprofile=""
# of loops: 76000 (including 1 artificial root node)

#open the generated profiling data and export it as callgrind file
go tool pprof havlak2
Entering interactive mode (type "help" for commands)
callgrind[press enter]
Generating report in profile001.callgraph.out
quit[press enter]

The callgrind data is exported to profile001.callgraph.out

To use the hide-sys feature of Profiling Viewer you must enter the path of your Golang installation under Preferences/Hide System.

Open the file "profile001.callgraph.out" with Profiling Viewer

For opening profiling files generated by xdebug on MacOS, my app Profiling Viewer can come in handy. Take a look at Profiling Viewer