gpt4 book ai didi

haskell - 如何将条件与堆栈一起使用

转载 作者:行者123 更新时间:2023-12-02 20:54:59 28 4
gpt4 key购买 nike

我设置了一个简单的堆栈项目和一个用于基准测试的 .cabal 条目:

benchmark leaves-of-a-tree-bench
type: exitcode-stdio-1.0
hs-source-dirs: src, bench
main-is: MainBenchmarkSuite.hs
build-depends: base
, criterion
, random
, leaves-of-a-tree
ghc-options: -Wall
-O2
default-language: Haskell2010

但是在运行stack bench后我收到以下错误:

setup-Simple-Cabal-1.22.5.0-ghc-7.10.3: Error: Could not find benchmark program      
".stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/leaves-of-a-tree-bench/leaves-of-a-tree-bench".
Did you build the package first?

我错过了什么吗?

编辑:我将项目上传到 a github repository

最佳答案

这里发生了一些奇怪的 cabal 事情。

您的LeavesOfATreeBench.hs :

-- |

module LeavesOfATreeBench where

import Criterion.Main
import Data.BinTree

mkTree :: [a] -> BinTree a
mkTree [] = Nil
mkTree (x:xs) = Fork x (mkTree lxs) (mkTree rxs)
where (lxs, rxs) = splitAt ((length xs + 1) `div` 2) xs

main :: IO ()
main = defaultMain [
bgroup "leaves"
[ bench "tree 0" $ whnf leaves (mkTree ([0 .. 20] :: [Integer]))
, bench "tree 1" $ whnf leaves (mkTree ([0 .. 200] :: [Integer]))
]
]

现在,一旦我简单地删除该行

module LeavesOfATreeBench where

一切都按预期进行:

Registering leaves-of-a-tree-0.1.0.0...
leaves-of-a-tree-0.1.0.0: benchmarks
Running 1 benchmarks...
Benchmark leaves-of-a-tree-bench: RUNNING...
benchmarking leaves/tree 0
time 41.81 ns (41.51 ns .. 42.29 ns)
0.999 R² (0.998 R² .. 0.999 R²)
mean 42.65 ns (42.12 ns .. 43.50 ns)
std dev 2.293 ns (1.526 ns .. 3.690 ns)
variance introduced by outliers: 75% (severely inflated)

benchmarking leaves/tree 1
time 71.11 ns (70.41 ns .. 71.84 ns)
0.999 R² (0.999 R² .. 0.999 R²)
mean 71.30 ns (70.45 ns .. 72.19 ns)
std dev 2.917 ns (2.431 ns .. 3.507 ns)
variance introduced by outliers: 62% (severely inflated)

Benchmark leaves-of-a-tree-bench: FINISH
Completed 2 action(s).

关于haskell - 如何将条件与堆栈一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37485522/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com