我正在尝试分析一个程序的数字,它具有一些依赖性。 Per Aleksander Dmitrov在Profile Haskell without installing installing profiling libraries for all dependencies中的答案,我正在使用cabal-dev来(尝试)构建所有依赖项并启用分析。我试过了
cabal-dev install --config=./cabal-dev.config
,其中cabal-dev.config为
library-profiling: True
executable-profiling: True
package-db: /home/christopher/school/senior/senior_thesis/windingnumber_integration/cabal-dev/packages-7.6.1.conf
local-repo: /home/christopher/school/senior/senior_thesis/windingnumber_integration/cabal-dev/packages
user-install: False
remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
remote-repo-cache: /home/christopher/.cabal/packages
optimization: True
build-summary: /home/christopher/school/senior/senior_thesis/windingnumber_integration/cabal-dev/logs/build.log
remote-build-reporting: anonymous
optimization: True
install-dirs user
prefix: /home/christopher/school/senior/senior_thesis/windingnumber_integration/cabal-dev/
install-dirs global
cabal-dev install --cabal-install-arg='--enable-library-profiling' --cabal-install-arg='--enable-executable-profiling'
(当然,rm -rf cabal-dev
介于两者之间,从原始环境开始。)在每种情况下,我得到:
arch% cabal-dev/bin/windingnumber +RTS -p
cabal-dev/bin/windingnumber +RTS -p
windingnumber: the flag -p requires the program to be built with -prof
windingnumber:
windingnumber: Usage: <prog> <args> [+RTS <rtsopts> | -RTS <args>] ... --RTS <args>
<snip>
---即,未启用分析。我该如何启用它?
ETA解决方案:将-prof
添加到项目的.cabal文件中的ghc-options中。显然在cabal-dev配置中设置`executable-profiling:True'并没有这样做。感谢Daniel Fischer。
答案 0 :(得分:4)
每次运行时cabal-dev
都会重写./cabal-dev/cabal.config
。但是,您可以修改~/.cabal/share/cabal-dev-$VERSION/admin/cabal-config.in
以设置默认值:
$ vim ~/.cabal/share/cabal-dev-0.9.1/admin/cabal-config.in
# Set executable-profiling and library-profiling to True
$ cabal unpack ghc-core
$ cd ghc-core-0.5.6
$ cabal-dev install --dependencies-only
$ cabal-dev configure -p
$ cabal-dev build
$ ./dist/build/ghc-core/ghc-core +RTS -p
# much success
如果您不想为使用cabal-dev
管理的所有项目启用分析,请使用--extra-config-file
选项(--config
只设置自动生成的配置文件的位置):
$ cat cabal-dev.config
executable-profiling: True
library-profiling: True
$ cabal-dev --extra-config-file='./cabal-dev.config' install
$ ./cabal-dev/bin/ghc-core +RTS -p
# success
建议不要使用.cabal文件中的ghc-options
字段来启用性能分析 - 您不希望从Hackage安装程序包的每个人都使用性能分析进行构建。使用cabal-dev configure -p --ghc-options="-fprof-auto"
仅对当前构建启用分析。