Skip to content
PAN, Myautsai edited this page Feb 3, 2016 · 3 revisions

If it's slow when you're using libmc or you want to make it faster, you should profile it to find the bottleneck. The recommended tool is callgrind.

First call the function you think it is slow in tests/profile_client.cpp and build it:

mkdir -p build
cd build
cmake ..
make

generate a call-graph:

$ valgrind --tool=callgrind ./tests/profile_client
==18375== Callgrind, a call-graph generating cache profiler
==18375== Copyright (C) 2002-2011, and GNU GPL'd, by Josef Weidendorfer et al.
==18375== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==18375== Command: ./tests/profile_client
==18375==
==18375== For interactive control, run 'callgrind_control -h'.
==18375==
==18375== Events    : Ir
==18375== Collected : 666129640
==18375==
==18375== I   refs:      666,129,640

You'll find the output file callgrind.out.18375 (18375 is the pid). If you are using OS X or Linux, you can open the call-graph using qcachegrind/kcachegrind. Then you'll find the bottleneck.