Commit 3de3a1e5 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel 🐢

Add more benchmarks for RefinablePartition

Specifically for make, make1 and mark
parent 9b6fe1a2
......@@ -11,7 +11,8 @@ import Control.DeepSeq
import Data.RefinablePartition
benchmarks :: Benchmark
benchmarks = bgroup "Data.RefinablePartition" [benchGroupBy]
benchmarks = bgroup "Data.RefinablePartition"
[benchGroupBy, benchMake, benchMake1, benchMark]
benchGroupBy :: Benchmark
benchGroupBy = bgroup
......@@ -34,6 +35,48 @@ benchGroupBy = bgroup
$ withInit (make 1000 1 (const 0)) (\p -> groupBy p 0 negate)
]
benchMake :: Benchmark
benchMake = bgroup
"make"
[ bench "1 block, 10 states" $ whnfIO (stToIO (make 10 1 (const 0)))
, bench "1 block, 20 states" $ whnfIO (stToIO (make 20 1 (const 0)))
, bench "1 block, 100 states" $ whnfIO (stToIO (make 100 1 (const 0)))
, bench "2 blocks, 10 states" $ whnfIO (stToIO (make 10 2 (bmod 2)))
, bench "2 blocks, 20 states" $ whnfIO (stToIO (make 20 2 (bmod 2)))
, bench "2 blocks, 100 states" $ whnfIO (stToIO (make 100 2 (bmod 2)))
, bench "10 blocks, 10 states" $ whnfIO (stToIO (make 10 10 Block))
, bench "20 blocks, 20 states" $ whnfIO (stToIO (make 20 20 Block))
, bench "100 blocks, 100 states" $ whnfIO (stToIO (make 100 100 Block))
]
where bmod n = Block . (`mod` n)
benchMake1 :: Benchmark
benchMake1 = bgroup
"make1"
[ bench "10 states" $ whnfIO (stToIO (make1 10))
, bench "20 states" $ whnfIO (stToIO (make1 20))
, bench "100 states" $ whnfIO (stToIO (make1 100))
]
-- hehe
benchMark :: Benchmark
benchMark = bgroup
"mark"
[ bench "0 states" $ withInit (make1 100) (\_ -> return ())
, bench "10 states" $ withInit (make1 100) (\p -> mapM_ (mark p) [0 .. 9])
, bench "20 states" $ withInit (make1 100) (\p -> mapM_ (mark p) [0 .. 19])
, bench "100 states" $ withInit (make1 100) (\p -> mapM_ (mark p) [0 .. 99])
, bench "10 states, reverse"
$ withInit (make1 100) (\p -> mapM_ (mark p) [9, 8 .. 0])
, bench "20 states, reverse"
$ withInit (make1 100) (\p -> mapM_ (mark p) [19, 18 .. 0])
, bench "100 states, reverse"
$ withInit (make1 100) (\p -> mapM_ (mark p) [99, 98 .. 0])
]
instance NFData (RefinablePartition RealWorld) where
rnf p = seq p ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment