【发布时间】:2014-08-03 15:39:40
【问题描述】:
在没有正常工作的 gprof 的情况下,我可以使用其他什么工具在 OS X 上进行分析?
(我知道穷人的方法,但更喜欢不需要手动代码检测的东西)
到目前为止,我一直没有安装完整的 Xcode,并尝试使用 Activity Monitor,但我不确定自己做对了吗?
详情: 我已经设法使用 ocamlbuild 和“.p.native”构建目标编译我的项目以进行时间分析。然后,我在 Mac OS X 10.9 上使用 Activity Monitor 对正在运行的进程进行采样。这提供了大量关于 OCaml 内部的输出,例如垃圾收集,但我没有从我的模块中看到正确注释的函数名称。
输出片段:
Call graph:
2109 Thread_55861 DispatchQueue_1: com.apple.main-thread (serial)
542 .L1099 (in atest.p.native) + 18 [0x101a89956]
+ 210 caml_weak_get (in atest.p.native) + 278 [0x101ac79e6]
+ ! 87 caml_alloc_small (in atest.p.native) + 22 [0x101ab75e6]
+ ! : 70 mcount (in libsystem_c.dylib) + 32,37,... [0x7fff87545620,0x7fff87545625,...]
+ ! : 10 mcount (in libsystem_c.dylib) + 59 [0x7fff8754563b]
+ ! : | 10 moncount (in libsystem_c.dylib) + 0,1,... [0x7fff8754d3a5,0x7fff8754d3a6,...]
+ ! : 7 DYLD-STUB$$moncount (in libsystem_c.dylib) + 0 [0x7fff875c549e]
+ ! 68 caml_alloc_small (in atest.p.native) + 1,128,... [0x101ab75d1,0x101ab7650,...]
+ ! 46 caml_alloc_small (in atest.p.native) + 87 [0x101ab7627]
+ ! : 40 caml_minor_collection (in atest.p.native) + 90 [0x101ab624a]
我在上面看到很多类似于 .L1099 的符号,但几乎没有一个具有 Module-name_function-name_unique-number 类型的专有名称,这是我阅读 OCaml 手册时所期望的。令人困惑的是,确实出现了一些人类可读的符号——但还不够有用。
另一个片段,其中最后一行是我自己模块中的函数
Sort by top of stack, same collapsed (when >= 5):
mcount (in libsystem_c.dylib) 617
caml_weak_get (in atest.p.native) 256
caml_alloc_small (in atest.p.native) 97
caml_modify (in atest.p.native) 94
moncount (in libsystem_c.dylib) 93
caml_c_call (in atest.p.native) 67
mark_slice (in atest.p.native) 42
caml_weak_set (in atest.p.native) 36
caml_page_table_lookup (in atest.p.native) 34
camlRandom__bits_1038 (in atest.p.native) 30
sweep_slice (in atest.p.native) 24
DYLD-STUB$$mcount (in atest.p.native) 23
DYLD-STUB$$moncount (in libsystem_c.dylib) 18
compare_val (in atest.p.native) 16
.L327 (in atest.p.native) 15
.L621 (in atest.p.native) 15
.L1202 (in atest.p.native) 14
.L1205 (in atest.p.native) 14
.L1173 (in atest.p.native) 12
.L1113 (in atest.p.native) 11
.L1281 (in atest.p.native) 11
.L1310 (in atest.p.native) 11
caml_fl_allocate (in atest.p.native) 11
caml_oldify_one (in atest.p.native) 11
caml_weak_blit (in atest.p.native) 11
.L1099 (in atest.p.native) 10
.L1150 (in atest.p.native) 10
.L135 (in atest.p.native) 10
.L149 (in atest.p.native) 10
.L295 (in atest.p.native) 10
caml_alloc_shr (in atest.p.native) 10
.L148 (in atest.p.native) 9
.L268 (in atest.p.native) 9
invert_pointer_at (in atest.p.native) 9
.L1135 (in atest.p.native) 8
.L1154 (in atest.p.native) 8
.L1278 (in atest.p.native) 8
allocate_block (in atest.p.native) 8
.L1114 (in atest.p.native) 7
.L1118 (in atest.p.native) 7
.L1172 (in atest.p.native) 7
.L131 (in atest.p.native) 7
camlReact__occurs_1470 (in atest.p.native) 7
camlReactor__compare_1235 (in atest.p.native) 7
【问题讨论】: