@@ -58,6 +58,46 @@ sourceUnfoldrM value n = S.unfoldrM step n
58 then return Nothing
58 then return Nothing
59 else return (Just (cnt, cnt + 1))
59 else return (Just (cnt, cnt + 1))
61+-- | Generates something like this: { { \{ \{ } }. The stream consists of
62+-- three parts, the first part is contains a sequence of `{`. The second part
63+-- contains a sequence pf escaped values `\{`. The third part contains a
65+{-# INLINE sourceEscapedFrames #-}
66+sourceEscapedFrames ::
67+ (S.IsStream t, S.MonadAsync m)
71+sourceEscapedFrames value n = S.unfoldrM step n
77+ value1 = value `div` 4
80+ | cnt > 4 * value1 = return Nothing
81+ | cnt <= value1 = return $ Just (cbOpen, cnt + 1)
82+ | cnt > 3 * value1 = return $ Just (cbClose, cnt + 1)
86+ $ if (cnt - value1) `mod` 2 == 1
88+ else (cbOpen, cnt + 1)
90+{-# INLINE benchIOSrc #-}
93+ => (Int -> Int -> t IO a)
98+benchIOSrc src value name f =
99+ bench name $ nfIO $ randomRIO (1,1) >>= f . src value
61-- | Takes a fold method, and uses it with a default source.
101-- | Takes a fold method, and uses it with a default source.
62{-# INLINE benchIOSink #-}
102{-# INLINE benchIOSink #-}
63benchIOSink
103benchIOSink
@@ -99,6 +139,17 @@ takeStartBy value stream = do
99 let stream2 = value `S.cons` stream1
139 let stream2 = value `S.cons` stream1
100 IP.parse (PR.takeStartBy (== value) FL.drain) stream2
140 IP.parse (PR.takeStartBy (== value) FL.drain) stream2
142+takeFramedByEsc_ :: MonadCatch m => Int -> SerialT m Char -> m ()
143+takeFramedByEsc_ _ = IP.parse parser
151+ parser = PR.takeFramedByEsc_ isEsc isBegin isEnd FL.drain
102{-# INLINE takeWhile #-}
153{-# INLINE takeWhile #-}
103takeWhile :: MonadCatch m => Int -> SerialT m Int -> m ()
154takeWhile :: MonadCatch m => Int -> SerialT m Int -> m ()
104takeWhile value = IP.parse (PR.takeWhile (<= value) FL.drain)
155takeWhile value = IP.parse (PR.takeWhile (<= value) FL.drain)
@@ -368,6 +419,8 @@ o_1_space_serial value =
368 , benchIOSink value "takeP" $ takeP value
419 , benchIOSink value "takeP" $ takeP value
369 , benchIOSink value "dropWhile" $ dropWhile value
420 , benchIOSink value "dropWhile" $ dropWhile value
370 , benchIOSink value "takeStartBy" $ takeStartBy value
421 , benchIOSink value "takeStartBy" $ takeStartBy value
422+ , benchIOSrc sourceEscapedFrames value "takeFramedByEsc_"
423+ $ takeFramedByEsc_ value
371 , benchIOSink value "groupBy" $ groupBy
424 , benchIOSink value "groupBy" $ groupBy
372 , benchIOSink value "groupByRolling" $ groupByRolling
425 , benchIOSink value "groupByRolling" $ groupByRolling
373 , benchIOSink value "wordBy" $ wordBy value
426 , benchIOSink value "wordBy" $ wordBy value