堆栈运行单一基准

问题描述 投票:0回答:2

我的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

如何使用Stack运行单一基准(如my-guage-bench)?

haskell benchmarking haskell-stack
2个回答
2
投票

你需要做这样的事情来运行一个基准:

stack bench package-name:my-guage-bench

2
投票

这适用于stack中的所有目标,无论是测试,基准测试还是可执行文件。

堆栈中有一个很酷的小命令可以帮助您列出所有可用的目标,而无需通过my-package.cabalpackage.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

现在我们知道了列表,我们可以调用特定的基准测试

$ stack bench my-package:bench:gauge another-package:bench:criterion
© www.soinside.com 2019 - 2024. All rights reserved.