我花了一整天试图让gperftools工作:/
我厌倦了不同的 libunwind 版本,但是当我成功安装它时,每当我使用 std::system 时,我都会收到以下错误“Profiling timer expired”。
主.cpp:
#include <cstdlib>
int main(int argc, char** argv) {
std::system("cut -f1 anyExistingFile | sort > newSortedFile");
return 0;
}
我厌倦了执行如下分析:
$ 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
然后我做了:
$ env LD_PRELOAD="/usr/local/lib/libprofiler.so"
$ sort file
$ env LD_PRELOAD=
$ sort file
当我将 LD_PRELOAD 设置为“/usr/local/lib/libprofiler.so”时,排序不起作用!
然后我尝试使用库的静态版本:
$ g++ main.cpp -o myApp -std=c++11 /usr/local/lib/libtcmalloc_and_profiler.a
$ env CPUPROFILE=out.prof ./myApp
什么也没发生,并且 out.prof 没有被创建!
所以我想知道为什么我在使用 std::system(sort) 时得到“分析计时器已过期”?它是使用 gperftools 库的静态版本的正确方法吗?
PS:64位,gperftools=2.5,libunwind=1.1,linux Ubuntu 16.04.1