on master help sign in
Add benchmark for decodeUtf8Lenient
f5d83bcHarendra Kumar
benchmark/FileIO.hs+1−1
@@ -134,7 +134,7 @@ main = do
134 BFS.copyCodecChar8 inh outh
134 BFS.copyCodecChar8 inh outh
135 , mkBench "utf8" href $ do
135 , mkBench "utf8" href $ do
136 Handles inh outh <- readIORef href
136 Handles inh outh <- readIORef href
137− BFS.copyCodecUtf8 inh outh
137+ BFS.copyCodecUtf8Lenient inh outh
138 ]
138 ]
139 , bgroup "grouping"
139 , bgroup "grouping"
140 [ mkBench "chunksOf (single chunk)" href $ do
140 [ mkBench "chunksOf (single chunk)" href $ do
src/Streamly/Benchmark/FileIO/Stream.hs+17
@@ -35,6 +35,7 @@ module Streamly.Benchmark.FileIO.Stream
35 , wordsUnwordsCopy
35 , wordsUnwordsCopy
36 , copyCodecChar8
36 , copyCodecChar8
37 , copyCodecUtf8
37 , copyCodecUtf8
38+ , copyCodecUtf8Lenient
38 , chunksOf
39 , chunksOf
39 , chunksOfD
40 , chunksOfD
40 , splitOn
41 , splitOn
@@ -217,6 +218,22 @@ inspect $ hasNoTypeClasses 'copyCodecUtf8
217-- inspect $ 'copyCodecUtf8 `hasNoType` ''D.ConcatMapUState
218-- inspect $ 'copyCodecUtf8 `hasNoType` ''D.ConcatMapUState
218#endif
219#endif
219
220
221+-- | Copy file
222+{-# INLINE copyCodecUtf8Lenient #-}
223+copyCodecUtf8Lenient :: Handle -> Handle -> IO ()
224+copyCodecUtf8Lenient inh outh =
225+ S.runFold (FH.write outh)
226+ $ SS.encodeUtf8
227+ $ SS.decodeUtf8Lenient
228+ $ FH.read inh
229+
230+#ifdef INSPECTION
231+inspect $ hasNoTypeClasses 'copyCodecUtf8Lenient
232+-- inspect $ 'copyCodecUtf8Lenient `hasNoType` ''Step
233+-- inspect $ 'copyCodecUtf8Lenient `hasNoType` ''AT.FlattenState
234+-- inspect $ 'copyCodecUtf8Lenient `hasNoType` ''D.ConcatMapUState
235+#endif
236+
220-- | Slice in chunks of size n and get the count of chunks.
237-- | Slice in chunks of size n and get the count of chunks.
221{-# INLINE chunksOf #-}
238{-# INLINE chunksOf #-}
222chunksOf :: Int -> Handle -> IO Int
239chunksOf :: Int -> Handle -> IO Int