测试时将 ekg 与堆栈一起使用
Using ekg with stack while testing
我写了一些耐力测试,我 运行 和 stack test
。我还使用 ekg
来监控性能。本套餐推荐:
To make full use out of this module you must first enable GC statistics collection in the run-time system. To enable GC statistics collection, either run your program with
+RTS -T
or compile it with
-with-rtsopts=-T
我知道堆栈支持 --profile
和 --trace
选项,但我找不到任何选项将 +RTS -T
选项传递给测试程序。我可以使用任何标志来实现这种效果吗?
正如 Mark 所说,使用 --test-arguments
为您的测试应用程序提供命令行参数:
stack test --test-arguments="+RTS -T"
如果您不使用 stack test
而使用 stack exec
,请确保禁用 stack
本身的 RTS 解析:
stack --RTS exec <executable-name> +RTS <rts-options>
另一种可能性是在 .cabal
(或 package.yaml
,如果使用 hpack
)文件中设置编译器选项:
ghc-options:
# ...
- -with-rtsopts=-N
# ... Add the -T options on top of the other `RTS` options:
- -with-rtsopts=-T
# ...
由于 -T
选项的开销很小,因此此方法不需要将任何标志传递给 stack
以获得相关的 ekg
指标。
我写了一些耐力测试,我 运行 和 stack test
。我还使用 ekg
来监控性能。本套餐推荐:
To make full use out of this module you must first enable GC statistics collection in the run-time system. To enable GC statistics collection, either run your program with
+RTS -T
or compile it with
-with-rtsopts=-T
我知道堆栈支持 --profile
和 --trace
选项,但我找不到任何选项将 +RTS -T
选项传递给测试程序。我可以使用任何标志来实现这种效果吗?
正如 Mark 所说,使用 --test-arguments
为您的测试应用程序提供命令行参数:
stack test --test-arguments="+RTS -T"
如果您不使用 stack test
而使用 stack exec
,请确保禁用 stack
本身的 RTS 解析:
stack --RTS exec <executable-name> +RTS <rts-options>
另一种可能性是在 .cabal
(或 package.yaml
,如果使用 hpack
)文件中设置编译器选项:
ghc-options:
# ...
- -with-rtsopts=-N
# ... Add the -T options on top of the other `RTS` options:
- -with-rtsopts=-T
# ...
由于 -T
选项的开销很小,因此此方法不需要将任何标志传递给 stack
以获得相关的 ekg
指标。