Chr*_*lor 3 profiling haskell ghc
我正在使用GHC 7.4.1并试图分析一段代码.不幸的是,分析器的输出为main功能分配了一个大的成本中心,而不是将其分解为每个功能的多个成本中心.
这是我正在遵循的用于分析代码的过程.我很欣赏指出我做错了什么.
首先,重新安装库,启用优化和分析:
cabal install -p -O2
Run Code Online (Sandbox Code Playgroud)
接下来,我重新编译我想要分析的代码:
ghc -rtsopts -prof -fprof-auto -fforce-recomp --make -O2 "Main.hs"
Run Code Online (Sandbox Code Playgroud)
最后,我使用一些分析选项运行它:
./Main +RTS -K100M -s -p -hy
Run Code Online (Sandbox Code Playgroud)
这就是结果:
COST CENTRE MODULE %time %alloc
main Main 100.0 100.0
Run Code Online (Sandbox Code Playgroud)
有什么明显我做错了吗?
的-auto-all(-fprof-auto如GHC 7.4)选项会自动标记所有顶级功能,包括那些没有出口,作为成本中心的.
但该选项仅影响当前编译的模块,因此可能还需要使用该选项编译库.为此,请在库的.cabal文件中设置ghc-prof-options: -O2 -auto-all(相应-fprof-auto).
注意:成本中心注释可能会对性能产生很大影响,因此,请-auto-all参阅.-fprof-auto只应用于当前正在检查的库中,其他库应使用较少的成本中心注释进行编译,以便进行分析-auto.-fprof-auto-top或-fprof-auto-exported.