I spent the whole day trying to make gperftools working :/
I tired different libunwind versions but when I successed in installing it I got the following error "Profiling timer expired" whenever I used std::system.
main.cpp:
#include <cstdlib>
int main(int argc, char** argv) {
std::system("cut -f1 anyExistingFile | sort > newSortedFile");
return 0;
}
I tired to perform profiling as following:
$ g++ main.cpp -o myApp -std=c++11
$ env CPUPROFILE=out.prof LD_PRELOAD="/usr/local/lib/libprofiler.so" ./myApp
Profiling timer expired
PROFILE: interrupts/evictions/bytes = 0/0/64
then I did:
$ env LD_PRELOAD="/usr/local/lib/libprofiler.so"
$ sort file
$ env LD_PRELOAD=
$ sort file
sort was not working when I had LD_PRELOAD set to "/usr/local/lib/libprofiler.so" !!
then I tried to use the static versions of the library:
$ g++ main.cpp -o myApp -std=c++11 /usr/local/lib/libtcmalloc_and_profiler.a
$ env CPUPROFILE=out.prof ./myApp
nothing happened, and out.prof was not created!
so I am wondering why I get "Profiling timer expired" when I use std::system(sort)? and is it the right way to use the static version of gperftools library?
P.S: 64-bit, gperftools=2.5, libunwind=1.1, linux Ubuntu 16.04.1