Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions benchmark/Streamly/Benchmark/CrossModule/Split.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ inspect $ 'wordsBy `hasNoType` ''Producer.ConcatState -- FH.read/UF.many
inspect $ 'wordsBy `hasNoType` ''MutArray.ArrayUnsafe -- FH.read/A.read
#endif

-- | Split on any of the word8 sequences.
splitOneOf :: [String] -> Handle -> IO Int
splitOneOf pats inh =
Stream.fold Fold.length
$ Stream.splitSepByOneOf (map toarr pats) Fold.drain
$ Handle.read inh

-- | Split on a word8 sequence.
splitOnSeq :: String -> Handle -> IO Int
splitOnSeq str inh =
Expand Down Expand Up @@ -274,6 +281,18 @@ benchmarks env =
, (SpaceO_1, mkBench "splitOnSeq KR infix 100k long pattern"
env $ \inh _ -> splitOnSeq100k inh)

-- Any of several patterns
, (SpaceO_1, mkBench "splitSepByOneOf lf" env $ \inh _ ->
splitOneOf ["\n"] inh)
, (SpaceO_1, mkBench "splitSepByOneOf crlf lf" env $ \inh _ ->
splitOneOf ["\r\n", "\n"] inh)
, (SpaceO_1, mkBench "splitSepByOneOf abcdefghi" env $ \inh _ ->
splitOneOf ["abcdefghi"] inh)
, (SpaceO_1, mkBench "splitSepByOneOf abc..z abcdefghi crlf"
env $ \inh _ ->
splitOneOf ["abcdefghijklmnopqrstuvwxyz", "abcdefghi", "\r\n"]
inh)

-- Suffix
, (SpaceO_1, mkBench "splitOnSuffixSeq empty suffix" env $ \inh _ ->
splitOnSuffixSeq "" inh)
Expand Down
Loading