gperftools与CPUPROFILE_FREQUENCY不一致
gperftools inexactitudes with CPUPROFILE_FREQUENCY
我有一个任务似乎无法使用gprof
。Callgrind在这里帮了很多忙,但当找到一个更像gprof
的解决方案,即gperftools时,请投入其中尝试。
所以我写了一个虚拟程序,做了几个这样的试验:
0:10:1386682334:user@host:~$ time gcc test.c -o test -lprofiler -Lgperftools-2.
1/.libs/ -g
real 0m0.085s
user 0m0.048s
sys 0m0.032s
0:11:1386682357:user@host:~$ time CPUPROFILE_FREQUENCY=50 CPUPROFILE=~
/test_profile LD_LIBRARY_PATH=~/gperftools-2.1/.libs/ ./test && ~/gperftools-2.
1/src/pprof test test_profile --text
PROFILE: interrupts/evictions/bytes = 14/0/216
real 0m7.157s
user 0m0.008s
sys 0m0.672s
Using local file test.
Using local file test_profile.
Removing killpg from all stack traces.
Removing do_system from all stack traces.
Total: 14 samples
14 100.0% 100.0% 14 100.0% do_system
0 0.0% 100.0% 14 100.0% __libc_start_main
0 0.0% 100.0% 14 100.0% _start
0 0.0% 100.0% 2 14.3% bar
0 0.0% 100.0% 14 100.0% foo
0 0.0% 100.0% 14 100.0% main
0:12:1386682465:user@host:~$ time CPUPROFILE_FREQUENCY=50000 CPUPROFIL
E=~/test_profile LD_LIBRARY_PATH=~/gperftools-2.1/.libs/ ./test && ~/gperftools
-2.1/src/pprof test test_profile --text
PROFILE: interrupts/evictions/bytes = 80/0/520
real 0m7.199s
user 0m0.016s
sys 0m0.704s
Using local file test.
Using local file test_profile.
Removing killpg from all stack traces.
Total: 80 samples
78 97.5% 97.5% 79 98.8% do_system
1 1.2% 98.8% 1 1.2% __find_specmb
1 1.2% 100.0% 1 1.2% __libc_waitpid
0 0.0% 100.0% 1 1.2% _IO_vfprintf_internal
0 0.0% 100.0% 80 100.0% __libc_start_main
0 0.0% 100.0% 1 1.2% __printf
0 0.0% 100.0% 80 100.0% _start
0 0.0% 100.0% 27 33.8% bar
0 0.0% 100.0% 79 98.8% foo
0 0.0% 100.0% 80 100.0% main
CPUPROFILE_FREQUENCY在这里被记录为默认值100,并且是cpu探查器采样的每秒中断次数。我对在7秒的模拟程序中将其设置为50只进行了14次采样感到疏远,而将其设置为50000只进行了80次采样。
我想知道,在需要的时候,通过这个简单的环境更改是否可以获得更高的精度,以及gperftools中是否损坏了CPUPROFILE_FREQUENCY。
您的程序只有0.008s到0.048s的用户执行时间。探查器只评测在用户空间中执行的时间,所以我认为您的结果是意料之中的。
试着运行一个花费7秒进行实际计算的伪程序。例如,计算阿克曼函数。
相关文章:
- 大于65535的C++数组[size]引发不一致的溢出
- 在 C++(和 C)中进行类型转换时明显不一致
- 填充上编译器生成的复制构造函数之间的不一致
- 犰狳的 print() 方法和 cout 在从 Rcpp 调用时顺序不一致
- CreateDIBSection为同一图像返回不一致的位图位值
- 在 Qml 中从 QSqlTableModel 中删除单行时视图不一致
- 模板参数推导不一致
- 声明中不一致的no是否违反ODR?
- 如何删除分支因子不一致的树,最大为 30,40
- 从 C++ 函数与 Python 函数返回的不一致值用于偏斜正态分布
- 从 C 字符串构造 std::string 与从另一个 std::string 构造 std::string 不一致
- 这种比较是否不一致(或者存在其他问题)?
- 以下可变参数模板行为是否不一致?
- 如何修复我的链表读数不一致的问题?
- 在C++17中,为什么类模板和函数模板的指针类型推导明显不一致
- void 函数中的指针参数返回不一致的值
- 如何查找导致结果不一致的代码
- 跨平台 mySQL 与字符集不一致
- C++:不一致的 std::p ow( 类型 ) 定义
- DLL 注入不断失败,出现不一致的错误