小编Alp*_*aca的帖子

列表的并行评估

我试图在Haskell中尝试并行评估,但似乎已经碰壁了.

就像一个实验一样,我想评估一个需要很长时间才能完成的任务列表.所以我想出了这个人为的例子.

import Control.Parallel.Strategies

startNum = 800000

bigList :: [Integer]
bigList = [2042^x | x <- [startNum..startNum+10]]

main = print $ sum $ parMap rdeepseq (length . show) bigList
Run Code Online (Sandbox Code Playgroud)

我编译了这个,ghc -O2 -eventlog -rtsopts -threaded test.hs --make然后运行了两次.

$ time ./test +RTS -N1 -lf -sstderr
29128678
   2,702,130,280 bytes allocated in the heap
      59,409,320 bytes copied during GC
       3,114,392 bytes maximum residency (68 sample(s))
       1,093,600 bytes maximum slop
              28 MB total memory in use (6 MB lost due to fragmentation)
                                    Tot …
Run Code Online (Sandbox Code Playgroud)

parallel-processing haskell

9
推荐指数
1
解决办法
215
查看次数

标签 统计

haskell ×1

parallel-processing ×1