on master help sign in
Add benchmarking code for lines/unlines, decode/encode.
commit2255dacd3e86482b1469c7b5196ad1d117974784 authorPranay Sashank <pranaysashank@gmail.com> dateWed 12 Jun 2019, 10:38 (7 years ago) parent94e11d0
1 file changed+34
benchmark/FileIO.hs+34
benchmark/FileIO.hs+34
@@ -18,6 +18,7 @@ import Gauge
1818import qualified Streamly.FileSystem.Handle as FH
1919import qualified Streamly.Mem.Array as A
2020import qualified Streamly.Prelude as S
21+import qualified Streamly.String as SS
2122
2223#ifdef DEVBUILD
2324import Data.Char (ord, chr)
@@ -133,6 +134,21 @@ main = do
133134 Handles inh outh <- readIORef href
134135 FH.write outh (FH.read inh)
135136 ]
137+ -- This needs an ascii file, as decode just errors out.
138+ , bgroup "decode/encode"
139+ [ mkBench "encodeChar8/decodeChar8" href $ do
140+ Handles inh outh <- readIORef href
141+ FH.write outh
142+ $ SS.encodeChar8
143+ $ SS.decodeChar8
144+ $ FH.read inh
145+ , mkBench "encodeUtf8/decodeUtf8" href $ do
146+ Handles inh outh <- readIORef href
147+ FH.write outh
148+ $ SS.encodeUtf8
149+ $ SS.decodeUtf8
150+ $ FH.read inh
151+ ]
136152 , bgroup "grouping"
137153 [ mkBench "chunksOf 1 (toArray)" href $ do
138154 Handles inh _ <- readIORef href
@@ -149,6 +165,24 @@ main = do
149165 Handles inh _ <- readIORef href
150166 S.length $ FL.chunksOf 1000 FL.drain (FH.read inh)
151167 ]
168+ , bgroup "group/ungroup"
169+ [ mkBench "lines/unlines" href $ do
170+ Handles inh outh <- readIORef href
171+ FH.write outh
172+ $ SS.encodeChar8
173+ $ SS.unlines
174+ $ SS.lines
175+ $ SS.decodeChar8
176+ $ FH.read inh
177+ , mkBench "words/unwords" href $ do
178+ Handles inh outh <- readIORef href
179+ FH.write outh
180+ $ SS.encodeChar8
181+ $ SS.unwords
182+ $ SS.words
183+ $ SS.decodeChar8
184+ $ FH.read inh
185+ ]
152186
153187 , let lf = fromIntegral (ord '\n')
154188 lfarr = A.fromList [lf]