on 8ec2ebe help sign in
streamly/benchmark/Nested.hs
60 lines 2.3 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)
12import Common (parseCLIOpts)
14import Streamly
15import Gauge
17import qualified NestedOps as Ops
19benchIO :: (NFData b) => String -> (Int -> IO b) -> Benchmark
20benchIO name f = bench name $ nfIO $ randomRIO (1,1) >>= f
22_benchId :: (NFData b) => String -> (Int -> Identity b) -> Benchmark
23_benchId name f = bench name $ nf (\g -> runIdentity (g 1)) f
25defaultStreamSize :: Int
26defaultStreamSize = 100000
28main :: IO ()
29main = do
30 -- XXX Fix indentation
31 (linearCount, cfg, benches) <- parseCLIOpts defaultStreamSize
32 runMode (mode cfg) cfg benches
33 [ bgroup "serially"
34 [ benchIO "toNullAp" $ Ops.toNullAp linearCount serially
35 , benchIO "toNull" $ Ops.toNull linearCount serially
36 , benchIO "toNull3" $ Ops.toNull3 linearCount serially
37 , benchIO "toList" $ Ops.toList linearCount serially
38 -- , benchIO "toListSome" $ Ops.toListSome serially
39 , benchIO "filterAllOut" $ Ops.filterAllOut linearCount serially
40 , benchIO "filterAllIn" $ Ops.filterAllIn linearCount serially
41 , benchIO "filterSome" $ Ops.filterSome linearCount serially
42 , benchIO "breakAfterSome" $ Ops.breakAfterSome linearCount serially
43 ]
45 , bgroup "wSerially"
46 [ benchIO "toNullAp" $ Ops.toNullAp linearCount wSerially
47 , benchIO "toNull" $ Ops.toNull linearCount wSerially
48 , benchIO "toNull3" $ Ops.toNull3 linearCount wSerially
49 , benchIO "toList" $ Ops.toList linearCount wSerially
50 -- , benchIO "toListSome" $ Ops.toListSome wSerially
51 , benchIO "filterAllOut" $ Ops.filterAllOut linearCount wSerially
52 , benchIO "filterAllIn" $ Ops.filterAllIn linearCount wSerially
53 , benchIO "filterSome" $ Ops.filterSome linearCount wSerially
54 , benchIO "breakAfterSome" $ Ops.breakAfterSome linearCount wSerially
55 ]
57 , bgroup "zipSerially"
58 [ benchIO "toNullAp" $ Ops.toNullAp linearCount zipSerially
59 ]
60 ]