Valgrind下载与安装
1、下载:
valgrind官网:http://valgrind.org下载
2、安装
cd valgrind ./autogen.sh ./configure --prefix=... make make install
3、执行
/opt/soft/valgrind/bin/valgrind --tool=memcheck --leak-check=full --log-file=./2log.txt ./test [程序参数]
gperftools下载与安装
1、下载及安装libunwind
下载地址: http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz
安装:
./configure --prefix=/home/your_name/tools/libunwind/ CFLAGS=-U_FORTRIFY_SOURCE make make install
2、下载及安装gperftools
git地址:https://github.com/gperftools/gperftools
安装:
./configure --prefix=/home/your_name/tools/gperftools LDFLAGS=-L/home/your_name/tools/libunwind/lib
CPPFLAGS=-I/home/your_name/tools/libunwind/include make make install
3、执行
//性能检测 env LD_PRELOAD="/opt/soft/gperft/lib/libprofiler.so" CPUPROFILE_FREQUENCY=100 CPUPROFILE=cpu_perf.prof ./test /opt/soft/gperft/bin/pprof --text ./test cpu_perf.prof > cpu_perf.text