Make sure you have Xcode command line tools (e.g. clang++
), brew
and go
.
# optional
brew install llvm
# pprof is its dependency
brew install gperftools
go get github.com/google/pprof
# compile gperftools from source code
git clone https://github.com/gperftools/gperftools.git
cd gperftools
./autogen.sh
./configure
make && make check
make install
# install pprof
go get github.com/google/pprof
# compile
clang++ -std=c++17 -Og -g3 -Wl,-no_pie -lprofiler puzzle.cpp -o puzzle # OS X
g++ -std=c++17 -Og -g3 -lprofiler puzzle.cpp -o puzzle # linux
# run
env CPUPROFILE=puzzle.prof ./puzzle -qo list < huge2.txt > output.txt
# report
pprof --list=main puzzle.prof
# compile
clang++ -std=c++17 -Og -g3 -Wl,-no_pie -ltcmalloc puzzle.cpp -o puzzle # OS X
g++ -std=c++17 -Og -g3 -ltcmalloc puzzle.cpp -o puzzle # linux
# run
env HEAPPROFILE=puzzle.prof ./puzzle -qo list < huge2.txt > output.txt
# report (specify the largest heap prof file)
pprof --list=main puzzle.prof.0003.heap
- You may need check the
GOPATH
and find thepprof
installed bygo get
. Usepprof
installed bygo
. - If you do not have root access, you need specify
prefix
and library path forprofiler
andtcmalloc
.