mirror of
https://github.com/composewell/streamly.git
synced 2024-09-19 07:29:02 +03:00
Fix benchmark names, cleanup imports, fix hlint
Refactor only.
This commit is contained in:
parent
fb1ee2e965
commit
f64dd78449
@ -64,4 +64,3 @@ benchmark/Streamly/Benchmark/Prelude/Serial/Transformation1.hs
|
|||||||
benchmark/Streamly/Benchmark/Prelude/WAsync.hs
|
benchmark/Streamly/Benchmark/Prelude/WAsync.hs
|
||||||
benchmark/Streamly/Benchmark/Prelude/ZipAsync.hs
|
benchmark/Streamly/Benchmark/Prelude/ZipAsync.hs
|
||||||
benchmark/Streamly/Benchmark/Prelude/ZipSerial.hs
|
benchmark/Streamly/Benchmark/Prelude/ZipSerial.hs
|
||||||
benchmark/Streamly/Benchmark/Unicode/Stream.hs
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
-- |
|
--
|
||||||
-- Module : Streamly.Unicode.Stream
|
-- Module : Streamly.Unicode.Stream
|
||||||
-- Copyright : (c) 2019 Composewell Technologies
|
-- Copyright : (c) 2019 Composewell Technologies
|
||||||
-- License : BSD-3-Clause
|
-- License : BSD-3-Clause
|
||||||
@ -21,16 +21,14 @@
|
|||||||
import Prelude hiding (last, length)
|
import Prelude hiding (last, length)
|
||||||
import System.IO (Handle)
|
import System.IO (Handle)
|
||||||
|
|
||||||
import qualified Streamly.Data.Fold as FL
|
import qualified Streamly.Data.Array.Foreign as Array
|
||||||
import qualified Streamly.Unicode.Stream as SS
|
import qualified Streamly.Data.Fold as Fold
|
||||||
import qualified Streamly.FileSystem.Handle as FH
|
import qualified Streamly.FileSystem.Handle as Handle
|
||||||
import qualified Streamly.Internal.Data.Unfold as IUF
|
import qualified Streamly.Internal.Data.Stream.IsStream as Stream
|
||||||
import qualified Streamly.Internal.Unicode.Stream as IUS
|
import qualified Streamly.Internal.Data.Unfold as Unfold
|
||||||
import qualified Streamly.Internal.FileSystem.Handle as IFH
|
import qualified Streamly.Internal.FileSystem.Handle as Handle
|
||||||
import qualified Streamly.Internal.Unicode.Array.Char as IUA
|
import qualified Streamly.Internal.Unicode.Array.Char as UnicodeArr
|
||||||
import qualified Streamly.Internal.Data.Stream.IsStream as IP
|
import qualified Streamly.Internal.Unicode.Stream as Unicode
|
||||||
import qualified Streamly.Data.Array.Foreign as A
|
|
||||||
import qualified Streamly.Prelude as S
|
|
||||||
|
|
||||||
import Gauge hiding (env)
|
import Gauge hiding (env)
|
||||||
import Streamly.Benchmark.Common
|
import Streamly.Benchmark.Common
|
||||||
@ -41,8 +39,8 @@ import Foreign.Storable (Storable)
|
|||||||
import Streamly.Internal.Data.Stream.StreamD.Type (Step(..))
|
import Streamly.Internal.Data.Stream.StreamD.Type (Step(..))
|
||||||
import qualified Streamly.Internal.Data.Fold.Type as Fold
|
import qualified Streamly.Internal.Data.Fold.Type as Fold
|
||||||
import qualified Streamly.Internal.Data.Tuple.Strict as Strict
|
import qualified Streamly.Internal.Data.Tuple.Strict as Strict
|
||||||
import qualified Streamly.Internal.Data.Array.Foreign.Type as AT
|
import qualified Streamly.Internal.Data.Array.Foreign.Type as Array
|
||||||
import qualified Streamly.Internal.Data.Array.Foreign.Mut.Type as MA
|
import qualified Streamly.Internal.Data.Array.Foreign.Mut.Type as MArray
|
||||||
|
|
||||||
import Test.Inspection
|
import Test.Inspection
|
||||||
#endif
|
#endif
|
||||||
@ -54,10 +52,10 @@ moduleName = "Unicode.Stream"
|
|||||||
{-# NOINLINE copyCodecUtf8ArraysLenient #-}
|
{-# NOINLINE copyCodecUtf8ArraysLenient #-}
|
||||||
copyCodecUtf8ArraysLenient :: Handle -> Handle -> IO ()
|
copyCodecUtf8ArraysLenient :: Handle -> Handle -> IO ()
|
||||||
copyCodecUtf8ArraysLenient inh outh =
|
copyCodecUtf8ArraysLenient inh outh =
|
||||||
S.fold (FH.write outh)
|
Stream.fold (Handle.write outh)
|
||||||
$ SS.encodeUtf8'
|
$ Unicode.encodeUtf8'
|
||||||
$ IUS.decodeUtf8Arrays
|
$ Unicode.decodeUtf8Arrays
|
||||||
$ IFH.toChunks inh
|
$ Handle.toChunks inh
|
||||||
|
|
||||||
#ifdef INSPECTION
|
#ifdef INSPECTION
|
||||||
inspect $ hasNoTypeClasses 'copyCodecUtf8ArraysLenient
|
inspect $ hasNoTypeClasses 'copyCodecUtf8ArraysLenient
|
||||||
@ -68,7 +66,7 @@ o_1_space_decode_encode_chunked :: BenchEnv -> [Benchmark]
|
|||||||
o_1_space_decode_encode_chunked env =
|
o_1_space_decode_encode_chunked env =
|
||||||
[ bgroup "decode-encode/toChunks"
|
[ bgroup "decode-encode/toChunks"
|
||||||
[
|
[
|
||||||
mkBenchSmall "decodeEncodeUtf8Lenient" env $ \inH outH ->
|
mkBenchSmall "encodeUtf8' . decodeUtf8Arrays" env $ \inH outH ->
|
||||||
copyCodecUtf8ArraysLenient inH outH
|
copyCodecUtf8ArraysLenient inH outH
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -80,60 +78,60 @@ o_1_space_decode_encode_chunked env =
|
|||||||
{-# NOINLINE linesUnlinesCopy #-}
|
{-# NOINLINE linesUnlinesCopy #-}
|
||||||
linesUnlinesCopy :: Handle -> Handle -> IO ()
|
linesUnlinesCopy :: Handle -> Handle -> IO ()
|
||||||
linesUnlinesCopy inh outh =
|
linesUnlinesCopy inh outh =
|
||||||
S.fold (FH.write outh)
|
Stream.fold (Handle.write outh)
|
||||||
$ SS.encodeLatin1'
|
$ Unicode.encodeLatin1'
|
||||||
$ IUS.unlines IUF.fromList
|
$ Unicode.unlines Unfold.fromList
|
||||||
$ S.splitOnSuffix (== '\n') FL.toList
|
$ Stream.splitOnSuffix (== '\n') Fold.toList
|
||||||
$ SS.decodeLatin1
|
$ Unicode.decodeLatin1
|
||||||
$ S.unfold FH.read inh
|
$ Stream.unfold Handle.read inh
|
||||||
|
|
||||||
{-# NOINLINE linesUnlinesArrayWord8Copy #-}
|
{-# NOINLINE linesUnlinesArrayWord8Copy #-}
|
||||||
linesUnlinesArrayWord8Copy :: Handle -> Handle -> IO ()
|
linesUnlinesArrayWord8Copy :: Handle -> Handle -> IO ()
|
||||||
linesUnlinesArrayWord8Copy inh outh =
|
linesUnlinesArrayWord8Copy inh outh =
|
||||||
S.fold (FH.write outh)
|
Stream.fold (Handle.write outh)
|
||||||
$ IP.interposeSuffix 10 A.read
|
$ Stream.interposeSuffix 10 Array.read
|
||||||
$ S.splitOnSuffix (== 10) A.write
|
$ Stream.splitOnSuffix (== 10) Array.write
|
||||||
$ S.unfold FH.read inh
|
$ Stream.unfold Handle.read inh
|
||||||
|
|
||||||
-- XXX splitSuffixOn requires -funfolding-use-threshold=150 for better fusion
|
-- XXX splitSuffixOn requires -funfolding-use-threshold=150 for better fusion
|
||||||
-- | Lines and unlines
|
-- | Lines and unlines
|
||||||
{-# NOINLINE linesUnlinesArrayCharCopy #-}
|
{-# NOINLINE linesUnlinesArrayCharCopy #-}
|
||||||
linesUnlinesArrayCharCopy :: Handle -> Handle -> IO ()
|
linesUnlinesArrayCharCopy :: Handle -> Handle -> IO ()
|
||||||
linesUnlinesArrayCharCopy inh outh =
|
linesUnlinesArrayCharCopy inh outh =
|
||||||
S.fold (FH.write outh)
|
Stream.fold (Handle.write outh)
|
||||||
$ SS.encodeLatin1'
|
$ Unicode.encodeLatin1'
|
||||||
$ IUA.unlines
|
$ UnicodeArr.unlines
|
||||||
$ IUA.lines
|
$ UnicodeArr.lines
|
||||||
$ SS.decodeLatin1
|
$ Unicode.decodeLatin1
|
||||||
$ S.unfold FH.read inh
|
$ Stream.unfold Handle.read inh
|
||||||
|
|
||||||
#ifdef INSPECTION
|
#ifdef INSPECTION
|
||||||
inspect $ hasNoTypeClassesExcept 'linesUnlinesArrayCharCopy [''Storable]
|
inspect $ hasNoTypeClassesExcept 'linesUnlinesArrayCharCopy [''Storable]
|
||||||
-- inspect $ 'linesUnlinesArrayCharCopy `hasNoType` ''Step
|
-- inspect $ 'linesUnlinesArrayCharCopy `hasNoType` ''Step
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
-- XXX to write this we need to be able to map decodeUtf8 on the A.read fold.
|
-- XXX to write this we need to be able to map decodeUtf8 on the Array.read fold.
|
||||||
-- For that we have to write decodeUtf8 as a Pipe.
|
-- For that we have to write decodeUtf8 as a Pipe.
|
||||||
{-
|
{-
|
||||||
{-# INLINE linesUnlinesArrayUtf8Copy #-}
|
{-# INLINE linesUnlinesArrayUtf8Copy #-}
|
||||||
linesUnlinesArrayUtf8Copy :: Handle -> Handle -> IO ()
|
linesUnlinesArrayUtf8Copy :: Handle -> Handle -> IO ()
|
||||||
linesUnlinesArrayUtf8Copy inh outh =
|
linesUnlinesArrayUtf8Copy inh outh =
|
||||||
S.fold (FH.write outh)
|
Stream.fold (Handle.write outh)
|
||||||
$ SS.encodeLatin1'
|
$ Unicode.encodeLatin1'
|
||||||
$ IP.intercalate (A.fromList [10]) (pipe SS.decodeUtf8P A.read)
|
$ Stream.intercalate (Array.fromList [10]) (pipe Unicode.decodeUtf8P Array.read)
|
||||||
$ S.splitOnSuffix (== '\n') (IFL.map SS.encodeUtf8' A.write)
|
$ Stream.splitOnSuffix (== '\n') (IFold.map Unicode.encodeUtf8' Array.write)
|
||||||
$ SS.decodeLatin1
|
$ Unicode.decodeLatin1
|
||||||
$ S.unfold FH.read inh
|
$ Stream.unfold Handle.read inh
|
||||||
-}
|
-}
|
||||||
|
|
||||||
-- | Word, unwords and copy
|
-- | Word, unwords and copy
|
||||||
{-# NOINLINE wordsUnwordsCopyWord8 #-}
|
{-# NOINLINE wordsUnwordsCopyWord8 #-}
|
||||||
wordsUnwordsCopyWord8 :: Handle -> Handle -> IO ()
|
wordsUnwordsCopyWord8 :: Handle -> Handle -> IO ()
|
||||||
wordsUnwordsCopyWord8 inh outh =
|
wordsUnwordsCopyWord8 inh outh =
|
||||||
S.fold (FH.write outh)
|
Stream.fold (Handle.write outh)
|
||||||
$ IP.interposeSuffix 32 IUF.fromList
|
$ Stream.interposeSuffix 32 Unfold.fromList
|
||||||
$ S.wordsBy isSp FL.toList
|
$ Stream.wordsBy isSp Fold.toList
|
||||||
$ S.unfold FH.read inh
|
$ Stream.unfold Handle.read inh
|
||||||
|
|
||||||
#ifdef INSPECTION
|
#ifdef INSPECTION
|
||||||
inspect $ hasNoTypeClasses 'wordsUnwordsCopyWord8
|
inspect $ hasNoTypeClasses 'wordsUnwordsCopyWord8
|
||||||
@ -144,9 +142,9 @@ inspect $ hasNoTypeClasses 'wordsUnwordsCopyWord8
|
|||||||
{-# NOINLINE wordsUnwordsCopy #-}
|
{-# NOINLINE wordsUnwordsCopy #-}
|
||||||
wordsUnwordsCopy :: Handle -> Handle -> IO ()
|
wordsUnwordsCopy :: Handle -> Handle -> IO ()
|
||||||
wordsUnwordsCopy inh outh =
|
wordsUnwordsCopy inh outh =
|
||||||
S.fold (FH.write outh)
|
Stream.fold (Handle.write outh)
|
||||||
$ SS.encodeLatin1'
|
$ Unicode.encodeLatin1'
|
||||||
$ IUS.unwords IUF.fromList
|
$ Unicode.unwords Unfold.fromList
|
||||||
-- XXX This pipeline does not fuse with wordsBy but fuses with splitOn
|
-- XXX This pipeline does not fuse with wordsBy but fuses with splitOn
|
||||||
-- with -funfolding-use-threshold=300. With wordsBy it does not fuse
|
-- with -funfolding-use-threshold=300. With wordsBy it does not fuse
|
||||||
-- even with high limits for inlining and spec-constr ghc options. With
|
-- even with high limits for inlining and spec-constr ghc options. With
|
||||||
@ -154,10 +152,10 @@ wordsUnwordsCopy inh outh =
|
|||||||
-- is no evidence in the core that a join point involving Step
|
-- is no evidence in the core that a join point involving Step
|
||||||
-- constructors is not getting inlined. Not being able to fuse at all in
|
-- constructors is not getting inlined. Not being able to fuse at all in
|
||||||
-- this case could be an unknown issue, need more investigation.
|
-- this case could be an unknown issue, need more investigation.
|
||||||
$ S.wordsBy isSpace FL.toList
|
$ Stream.wordsBy isSpace Fold.toList
|
||||||
-- -- $ S.splitOn isSpace FL.toList
|
-- -- $ Stream.splitOn isSpace Fold.toList
|
||||||
$ SS.decodeLatin1
|
$ Unicode.decodeLatin1
|
||||||
$ S.unfold FH.read inh
|
$ Stream.unfold Handle.read inh
|
||||||
|
|
||||||
#ifdef INSPECTION
|
#ifdef INSPECTION
|
||||||
-- inspect $ hasNoTypeClasses 'wordsUnwordsCopy
|
-- inspect $ hasNoTypeClasses 'wordsUnwordsCopy
|
||||||
@ -167,28 +165,28 @@ wordsUnwordsCopy inh outh =
|
|||||||
{-# NOINLINE wordsUnwordsCharArrayCopy #-}
|
{-# NOINLINE wordsUnwordsCharArrayCopy #-}
|
||||||
wordsUnwordsCharArrayCopy :: Handle -> Handle -> IO ()
|
wordsUnwordsCharArrayCopy :: Handle -> Handle -> IO ()
|
||||||
wordsUnwordsCharArrayCopy inh outh =
|
wordsUnwordsCharArrayCopy inh outh =
|
||||||
S.fold (FH.write outh)
|
Stream.fold (Handle.write outh)
|
||||||
$ SS.encodeLatin1'
|
$ Unicode.encodeLatin1'
|
||||||
$ IUA.unwords
|
$ UnicodeArr.unwords
|
||||||
$ IUA.words
|
$ UnicodeArr.words
|
||||||
$ SS.decodeLatin1
|
$ Unicode.decodeLatin1
|
||||||
$ S.unfold FH.read inh
|
$ Stream.unfold Handle.read inh
|
||||||
|
|
||||||
o_1_space_copy_read_group_ungroup :: BenchEnv -> [Benchmark]
|
o_1_space_copy_read_group_ungroup :: BenchEnv -> [Benchmark]
|
||||||
o_1_space_copy_read_group_ungroup env =
|
o_1_space_copy_read_group_ungroup env =
|
||||||
[ bgroup "ungroup-group"
|
[ bgroup "ungroup-group"
|
||||||
[ mkBenchSmall "US.unlines . S.splitOnSuffix ([Word8])" env
|
[ mkBenchSmall "unlines . splitOnSuffix ([Word8])" env
|
||||||
$ \inh outh -> linesUnlinesCopy inh outh
|
$ \inh outh -> linesUnlinesCopy inh outh
|
||||||
, mkBenchSmall "S.interposeSuffix . S.splitOnSuffix(Array Word8)" env
|
, mkBenchSmall "interposeSuffix . splitOnSuffix (Array Word8)" env
|
||||||
$ \inh outh -> linesUnlinesArrayWord8Copy inh outh
|
$ \inh outh -> linesUnlinesArrayWord8Copy inh outh
|
||||||
, mkBenchSmall "UA.unlines . UA.lines (Array Char)" env
|
, mkBenchSmall "UnicodeArr.unlines . UnicodeArr.lines (Array Char)" env
|
||||||
$ \inh outh -> linesUnlinesArrayCharCopy inh outh
|
$ \inh outh -> linesUnlinesArrayCharCopy inh outh
|
||||||
|
|
||||||
, mkBenchSmall "S.interposeSuffix . S.wordsBy ([Word8])" env
|
, mkBenchSmall "interposeSuffix . wordsBy ([Word8])" env
|
||||||
$ \inh outh -> wordsUnwordsCopyWord8 inh outh
|
$ \inh outh -> wordsUnwordsCopyWord8 inh outh
|
||||||
, mkBenchSmall "US.unwords . S.wordsBy ([Char])" env
|
, mkBenchSmall "unwords . wordsBy ([Char])" env
|
||||||
$ \inh outh -> wordsUnwordsCopy inh outh
|
$ \inh outh -> wordsUnwordsCopy inh outh
|
||||||
, mkBenchSmall "UA.unwords . UA.words (Array Char)" env
|
, mkBenchSmall "UnicodeArr.unwords . UnicodeArr.words (Array Char)" env
|
||||||
$ \inh outh -> wordsUnwordsCharArrayCopy inh outh
|
$ \inh outh -> wordsUnwordsCharArrayCopy inh outh
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -201,55 +199,55 @@ o_1_space_copy_read_group_ungroup env =
|
|||||||
{-# NOINLINE copyStreamLatin1' #-}
|
{-# NOINLINE copyStreamLatin1' #-}
|
||||||
copyStreamLatin1' :: Handle -> Handle -> IO ()
|
copyStreamLatin1' :: Handle -> Handle -> IO ()
|
||||||
copyStreamLatin1' inh outh =
|
copyStreamLatin1' inh outh =
|
||||||
S.fold (FH.write outh)
|
Stream.fold (Handle.write outh)
|
||||||
$ SS.encodeLatin1'
|
$ Unicode.encodeLatin1'
|
||||||
$ SS.decodeLatin1
|
$ Unicode.decodeLatin1
|
||||||
$ S.unfold FH.read inh
|
$ Stream.unfold Handle.read inh
|
||||||
|
|
||||||
#ifdef INSPECTION
|
#ifdef INSPECTION
|
||||||
inspect $ hasNoTypeClasses 'copyStreamLatin1'
|
inspect $ hasNoTypeClasses 'copyStreamLatin1'
|
||||||
inspect $ 'copyStreamLatin1' `hasNoType` ''Step
|
inspect $ 'copyStreamLatin1' `hasNoType` ''Step
|
||||||
inspect $ 'copyStreamLatin1' `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
|
inspect $ 'copyStreamLatin1' `hasNoType` ''Unfold.ConcatState -- Handle.read/UF.many
|
||||||
inspect $ 'copyStreamLatin1' `hasNoType` ''MA.ReadUState -- FH.read/A.read
|
inspect $ 'copyStreamLatin1' `hasNoType` ''MArray.ReadUState -- Handle.read/Array.read
|
||||||
|
|
||||||
inspect $ 'copyStreamLatin1' `hasNoType` ''Fold.Step
|
inspect $ 'copyStreamLatin1' `hasNoType` ''Fold.Step
|
||||||
inspect $ 'copyStreamLatin1' `hasNoType` ''AT.ArrayUnsafe -- FH.write/writeNUnsafe
|
inspect $ 'copyStreamLatin1' `hasNoType` ''Array.ArrayUnsafe -- Handle.write/writeNUnsafe
|
||||||
inspect $ 'copyStreamLatin1' `hasNoType` ''Strict.Tuple3' -- FH.write/chunksOf
|
inspect $ 'copyStreamLatin1' `hasNoType` ''Strict.Tuple3' -- Handle.write/chunksOf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
-- | Copy file (encodeLatin1)
|
-- | Copy file (encodeLatin1)
|
||||||
{-# NOINLINE copyStreamLatin1 #-}
|
{-# NOINLINE copyStreamLatin1 #-}
|
||||||
copyStreamLatin1 :: Handle -> Handle -> IO ()
|
copyStreamLatin1 :: Handle -> Handle -> IO ()
|
||||||
copyStreamLatin1 inh outh =
|
copyStreamLatin1 inh outh =
|
||||||
S.fold (FH.write outh)
|
Stream.fold (Handle.write outh)
|
||||||
$ SS.encodeLatin1
|
$ Unicode.encodeLatin1
|
||||||
$ SS.decodeLatin1
|
$ Unicode.decodeLatin1
|
||||||
$ S.unfold FH.read inh
|
$ Stream.unfold Handle.read inh
|
||||||
|
|
||||||
#ifdef INSPECTION
|
#ifdef INSPECTION
|
||||||
inspect $ hasNoTypeClasses 'copyStreamLatin1
|
inspect $ hasNoTypeClasses 'copyStreamLatin1
|
||||||
inspect $ 'copyStreamLatin1 `hasNoType` ''Step
|
inspect $ 'copyStreamLatin1 `hasNoType` ''Step
|
||||||
inspect $ 'copyStreamLatin1 `hasNoType` ''IUF.ConcatState -- FH.read/UF.many
|
inspect $ 'copyStreamLatin1 `hasNoType` ''Unfold.ConcatState -- Handle.read/UF.many
|
||||||
inspect $ 'copyStreamLatin1 `hasNoType` ''MA.ReadUState -- FH.read/A.read
|
inspect $ 'copyStreamLatin1 `hasNoType` ''MArray.ReadUState -- Handle.read/Array.read
|
||||||
|
|
||||||
inspect $ 'copyStreamLatin1 `hasNoType` ''Fold.ManyState
|
inspect $ 'copyStreamLatin1 `hasNoType` ''Fold.ManyState
|
||||||
inspect $ 'copyStreamLatin1 `hasNoType` ''Fold.Step
|
inspect $ 'copyStreamLatin1 `hasNoType` ''Fold.Step
|
||||||
inspect $ 'copyStreamLatin1 `hasNoType` ''AT.ArrayUnsafe -- FH.write/writeNUnsafe
|
inspect $ 'copyStreamLatin1 `hasNoType` ''Array.ArrayUnsafe -- Handle.write/writeNUnsafe
|
||||||
inspect $ 'copyStreamLatin1 `hasNoType` ''Strict.Tuple3' -- FH.write/chunksOf
|
inspect $ 'copyStreamLatin1 `hasNoType` ''Strict.Tuple3' -- Handle.write/chunksOf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
-- | Copy file
|
-- | Copy file
|
||||||
_copyStreamUtf8' :: Handle -> Handle -> IO ()
|
_copyStreamUtf8' :: Handle -> Handle -> IO ()
|
||||||
_copyStreamUtf8' inh outh =
|
_copyStreamUtf8' inh outh =
|
||||||
S.fold (FH.write outh)
|
Stream.fold (Handle.write outh)
|
||||||
$ SS.encodeUtf8'
|
$ Unicode.encodeUtf8'
|
||||||
$ SS.decodeUtf8'
|
$ Unicode.decodeUtf8'
|
||||||
$ S.unfold FH.read inh
|
$ Stream.unfold Handle.read inh
|
||||||
|
|
||||||
#ifdef INSPECTION
|
#ifdef INSPECTION
|
||||||
inspect $ hasNoTypeClasses '_copyStreamUtf8'
|
inspect $ hasNoTypeClasses '_copyStreamUtf8'
|
||||||
-- inspect $ '_copyStreamUtf8 `hasNoType` ''Step
|
-- inspect $ '_copyStreamUtf8 `hasNoType` ''Step
|
||||||
-- inspect $ '_copyStreamUtf8 `hasNoType` ''AT.FlattenState
|
-- inspect $ '_copyStreamUtf8 `hasNoType` ''Array.FlattenState
|
||||||
-- inspect $ '_copyStreamUtf8 `hasNoType` ''D.ConcatMapUState
|
-- inspect $ '_copyStreamUtf8 `hasNoType` ''D.ConcatMapUState
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -257,15 +255,15 @@ inspect $ hasNoTypeClasses '_copyStreamUtf8'
|
|||||||
{-# NOINLINE copyStreamUtf8 #-}
|
{-# NOINLINE copyStreamUtf8 #-}
|
||||||
copyStreamUtf8 :: Handle -> Handle -> IO ()
|
copyStreamUtf8 :: Handle -> Handle -> IO ()
|
||||||
copyStreamUtf8 inh outh =
|
copyStreamUtf8 inh outh =
|
||||||
S.fold (FH.write outh)
|
Stream.fold (Handle.write outh)
|
||||||
$ SS.encodeUtf8
|
$ Unicode.encodeUtf8
|
||||||
$ SS.decodeUtf8
|
$ Unicode.decodeUtf8
|
||||||
$ S.unfold FH.read inh
|
$ Stream.unfold Handle.read inh
|
||||||
|
|
||||||
#ifdef INSPECTION
|
#ifdef INSPECTION
|
||||||
inspect $ hasNoTypeClasses 'copyStreamUtf8
|
inspect $ hasNoTypeClasses 'copyStreamUtf8
|
||||||
-- inspect $ 'copyStreamUtf8Lax `hasNoType` ''Step
|
-- inspect $ 'copyStreamUtf8Lax `hasNoType` ''Step
|
||||||
-- inspect $ 'copyStreamUtf8Lax `hasNoType` ''AT.FlattenState
|
-- inspect $ 'copyStreamUtf8Lax `hasNoType` ''Array.FlattenState
|
||||||
-- inspect $ 'copyStreamUtf8Lax `hasNoType` ''D.ConcatMapUState
|
-- inspect $ 'copyStreamUtf8Lax `hasNoType` ''D.ConcatMapUState
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -274,15 +272,16 @@ o_1_space_decode_encode_read env =
|
|||||||
[ bgroup "decode-encode"
|
[ bgroup "decode-encode"
|
||||||
[
|
[
|
||||||
-- This needs an ascii file, as decode just errors out.
|
-- This needs an ascii file, as decode just errors out.
|
||||||
mkBench "SS.encodeLatin1' . SS.decodeLatin1" env $ \inh outh ->
|
mkBench "encodeLatin1' . decodeLatin1" env $ \inh outh ->
|
||||||
copyStreamLatin1' inh outh
|
copyStreamLatin1' inh outh
|
||||||
, mkBench "SS.encodeLatin1 . SS.decodeLatin1" env $ \inh outh ->
|
, mkBench "encodeLatin1 . decodeLatin1" env $ \inh outh ->
|
||||||
copyStreamLatin1 inh outh
|
copyStreamLatin1 inh outh
|
||||||
#ifdef DEVBUILD
|
#ifdef DEVBUILD
|
||||||
, mkBench "copyUtf8" env $ \inh outh ->
|
-- Requires valid unicode input
|
||||||
|
, mkBench "encodeUtf8' . decodeUtf8'" env $ \inh outh ->
|
||||||
_copyStreamUtf8' inh outh
|
_copyStreamUtf8' inh outh
|
||||||
#endif
|
#endif
|
||||||
, mkBenchSmall "SS.encodeUtf8 . SS.decodeUtf8Lax" env $ \inh outh ->
|
, mkBenchSmall "encodeUtf8 . decodeUtf8" env $ \inh outh ->
|
||||||
copyStreamUtf8 inh outh
|
copyStreamUtf8 inh outh
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -296,7 +295,7 @@ main = do
|
|||||||
where
|
where
|
||||||
|
|
||||||
allBenchmarks env =
|
allBenchmarks env =
|
||||||
[ bgroup (o_1_space_prefix moduleName) $ Prelude.concat $
|
[ bgroup (o_1_space_prefix moduleName) $ Prelude.concat
|
||||||
[ o_1_space_copy_read_group_ungroup env
|
[ o_1_space_copy_read_group_ungroup env
|
||||||
, o_1_space_decode_encode_chunked env
|
, o_1_space_decode_encode_chunked env
|
||||||
, o_1_space_decode_encode_read env
|
, o_1_space_decode_encode_read env
|
||||||
|
Loading…
Reference in New Issue
Block a user