运行基准测试时出现堆栈错误(tasty-bench)

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

我尝试在我的 Haskell 包中包含一些基准测试,并运行

stack bench
生成错误:

Benchmark benchmarks: RUNNING...
All
  Fibonacci numbers
    fifth:     OK (4.28s)
      247  ns ±  17 ns
    tenth:     OK (5.88s)
Completed 3 action(s).

Error: [S-7282]
       Stack failed to execute the build plan.

       While executing the build plan, Stack encountered the error:

       <stderr>: commitAndReleaseBuffer: invalid argument (cannot encode character '\956')

这是 cabal 文件的相关部分:

benchmark benchmarks
  type:                 exitcode-stdio-1.0
  main-is:              Main.hs
  hs-source-dirs:       benchmarks/
  Build-Depends:        base >= 4.7 && < 5
                      , tasty-bench
                      , hspray
  default-language:     Haskell2010

这是代码:

module Main where
import Test.Tasty.Bench ( bench, bgroup, defaultMain, nf )

fibo :: Int -> Integer
fibo n = if n < 2 then toInteger n else fibo (n - 1) + fibo (n - 2)

main :: IO ()
main = defaultMain
  [ bgroup "Fibonacci numbers"
    [ bench "fifth"     $ nf fibo  5
    , bench "tenth"     $ nf fibo 10
    , bench "twentieth" $ nf fibo 20
    ]
  ]

我升级了stack并且运行了

stack clean
。我使用最新的 lts 版本的 ghc。我在 Windows 上。

haskell haskell-stack
1个回答
0
投票

在运行

chcp 65001
之前在控制台中运行
stack bench
解决了这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.