on 511fe85 help sign in
streamly/benchmark/Nested.hs
52 lines 2.0 kB history raw
1-- |
2-- Module : Main
3-- Copyright : (c) 2018 Harendra Kumar
4--
5-- License : BSD3
6-- Maintainer : streamly@composewell.com
8import Control.DeepSeq (NFData)
9import Data.Functor.Identity (Identity, runIdentity)
10import System.Random (randomRIO)
11import qualified NestedOps as Ops
12import Streamly
13import Gauge
15benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
16benchIO name f = bench name $ nfIO $ randomRIO (1,1) >>= f
18_benchId :: (NFData b) => String -> (Int -> Identity b) -> Benchmark
19_benchId name f = bench name $ nf (\g -> runIdentity (g 1)) f
21main :: IO ()
22main =
23 -- TBD Study scaling with 10, 100, 1000 loop iterations
24 defaultMain
25 [ bgroup "serially"
26 [ benchIO "toNullAp" $ Ops.toNullAp serially
27 , benchIO "toNull" $ Ops.toNull serially
28 , benchIO "toNull3" $ Ops.toNull3 serially
29 , benchIO "toList" $ Ops.toList serially
30 -- , benchIO "toListSome" $ Ops.toListSome serially
31 , benchIO "filterAllOut" $ Ops.filterAllOut serially
32 , benchIO "filterAllIn" $ Ops.filterAllIn serially
33 , benchIO "filterSome" $ Ops.filterSome serially
34 , benchIO "breakAfterSome" $ Ops.breakAfterSome serially
35 ]
37 , bgroup "wSerially"
38 [ benchIO "toNullAp" $ Ops.toNullAp wSerially
39 , benchIO "toNull" $ Ops.toNull wSerially
40 , benchIO "toNull3" $ Ops.toNull3 wSerially
41 , benchIO "toList" $ Ops.toList wSerially
42 -- , benchIO "toListSome" $ Ops.toListSome wSerially
43 , benchIO "filterAllOut" $ Ops.filterAllOut wSerially
44 , benchIO "filterAllIn" $ Ops.filterAllIn wSerially
45 , benchIO "filterSome" $ Ops.filterSome wSerially
46 , benchIO "breakAfterSome" $ Ops.breakAfterSome wSerially
47 ]
49 , bgroup "zipSerially"
50 [ benchIO "toNullAp" $ Ops.toNullAp zipSerially
51 ]
52 ]