on master help sign in
Add benchmark for decodeUtf8Lenient
commitf5d83bc8668a8acb918255bc4a5741c5a468cc36 authorHarendra Kumar <harendra.kumar@gmail.com> dateWed 11 Sep 2019, 11:03 (7 years ago) parent3e30855
2 files changed+18−1
benchmark/FileIO.hs+1−1 src/Streamly/Benchmark/FileIO/Stream.hs+17
benchmark/FileIO.hs+1−1
@@ -134,7 +134,7 @@ main = do
134134 BFS.copyCodecChar8 inh outh
135135 , mkBench "utf8" href $ do
136136 Handles inh outh <- readIORef href
137− BFS.copyCodecUtf8 inh outh
137+ BFS.copyCodecUtf8Lenient inh outh
138138 ]
139139 , bgroup "grouping"
140140 [ mkBench "chunksOf (single chunk)" href $ do
src/Streamly/Benchmark/FileIO/Stream.hs+17
@@ -35,6 +35,7 @@ module Streamly.Benchmark.FileIO.Stream
3535 , wordsUnwordsCopy
3636 , copyCodecChar8
3737 , copyCodecUtf8
38+ , copyCodecUtf8Lenient
3839 , chunksOf
3940 , chunksOfD
4041 , splitOn
@@ -217,6 +218,22 @@ inspect $ hasNoTypeClasses 'copyCodecUtf8
217218-- inspect $ 'copyCodecUtf8 `hasNoType` ''D.ConcatMapUState
218219#endif
219220
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+
220237-- | Slice in chunks of size n and get the count of chunks.
221238{-# INLINE chunksOf #-}
222239chunksOf :: Int -> Handle -> IO Int