Sib*_*ibi 2 benchmarking haskell haskell-stack
我的 cabal 文件中定义了多个基准:
benchmark my-gauge-bench
type: exitcode-stdio-1.0
main-is: Main.hs
hs-source-dirs:
bench/gauge
ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -Wall -threaded -rtsopts -with-rtsopts=-N
build-depends:
QuickCheck
, base >=4.10 && <10
, bytestring
, gauge
default-language: Haskell2010
benchmark my-weigh-bench
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules:
Paths_pkg_core_gen
hs-source-dirs:
bench/weigh
ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -Wall
build-depends:
QuickCheck
, base >=4.10 && <10
, bytestring
, weigh
Run Code Online (Sandbox Code Playgroud)
如何my-guage-bench使用 Stack 仅运行单个基准测试(如 )?
这适用于 中的所有目标stack,无论是测试、基准测试还是可执行文件。
堆栈中有一个很酷的小命令,可以帮助您列出所有可用的目标,而无需求助于挖掘my-package.cabal或package.yaml文件。它对于多包项目特别有用,并且适用于packages:以下字段中列出的所有包stack.yaml:
$ stack ide targets
my-package:lib
my-package:test:doctests
my-package:test:tests
my-package:bench:weight
my-package:bench:gauge
another-package:lib
another-package:exe:my-cool-executable
another-package:test:doctests
another-package:test:tests
another-package:bench:weight
another-package:bench:criterion
Run Code Online (Sandbox Code Playgroud)
现在我们知道了列表,我们可以调用特定的基准
$ stack bench my-package:bench:gauge another-package:bench:criterion
Run Code Online (Sandbox Code Playgroud)