@@ -18,11 +18,11 @@ import Gauge
18import qualified Streamly.FileSystem.Handle as FH
18import qualified Streamly.FileSystem.Handle as FH
19import qualified Streamly.Mem.Array as A
19import qualified Streamly.Mem.Array as A
20import qualified Streamly.Prelude as S
20import qualified Streamly.Prelude as S
21+import qualified Streamly.Fold as FL
22+import qualified Streamly.String as SS
22#ifdef DEVBUILD
24#ifdef DEVBUILD
23import Data.Char (ord, chr)
25import Data.Char (ord, chr)
24−import qualified Streamly.Fold as FL
25−import qualified Streamly.String as SS
28-- Input and output file handles
28-- Input and output file handles
@@ -87,6 +87,7 @@ main = do
88 outHandle <- openFile outfile WriteMode
88 outHandle <- openFile outfile WriteMode
89 href <- newIORef $ Handles inHandle outHandle
89 href <- newIORef $ Handles inHandle outHandle
90+ devNull <- openFile "/dev/null" WriteMode
91 defaultMain
92 defaultMain
92 [ bgroup "readArray"
93 [ bgroup "readArray"
@@ -104,11 +105,17 @@ main = do
104 Handles inh _ <- readIORef href
105 Handles inh _ <- readIORef href
105 let s = FH.readArrays inh
106 let s = FH.readArrays inh
106 S.sum (S.map A.length s)
107 S.sum (S.map A.length s)
108+ , mkBench "linecount" href $ do
109+ Handles inh _ <- readIORef href
110+ S.length $ A.splitArraysOn 10 $ FH.readArrays inh
107 , mkBench "sum" href $ do
111 , mkBench "sum" href $ do
108 let foldlArr' f z = runIdentity . S.foldl' f z . A.read
112 let foldlArr' f z = runIdentity . S.foldl' f z . A.read
109 Handles inh _ <- readIORef href
113 Handles inh _ <- readIORef href
110 let s = FH.readArrays inh
114 let s = FH.readArrays inh
111 S.foldl' (\acc arr -> acc + foldlArr' (+) 0 arr) 0 s
115 S.foldl' (\acc arr -> acc + foldlArr' (+) 0 arr) 0 s
116+ , mkBench "cat" href $ do
117+ Handles inh _ <- readIORef href
118+ FH.writeArrays devNull $ FH.readArraysOfUpto (256*1024) inh
113 , bgroup "readStream"
120 , bgroup "readStream"
114 [ mkBench "last" href $ do
121 [ mkBench "last" href $ do
@@ -117,9 +124,18 @@ main = do
117 , mkBench "length (bytecount)" href $ do
124 , mkBench "length (bytecount)" href $ do
118 Handles inh _ <- readIORef href
125 Handles inh _ <- readIORef href
119 S.length $ FH.read inh
126 S.length $ FH.read inh
127+ , mkBench "linecount" href $ do
128+ Handles inh _ <- readIORef href
130+ $ flip SS.foldLines FL.drain
120 , mkBench "sum" href $ do
133 , mkBench "sum" href $ do
121 Handles inh _ <- readIORef href
134 Handles inh _ <- readIORef href
122 S.sum $ FH.read inh
135 S.sum $ FH.read inh
136+ , mkBench "cat" href $ do
137+ Handles inh _ <- readIORef href
138+ FH.write devNull $ FH.read inh
124 , bgroup "copyArray"
140 , bgroup "copyArray"
125 [ mkBench "copy" href $ do
141 [ mkBench "copy" href $ do