@@ -22,10 +22,11 @@
2222import Prelude hiding (zip)
2323
2424import Streamly (zipSerially)
25+import qualified Streamly as S
2526import qualified Streamly.Prelude as S
2627
2728import Streamly.Benchmark.Common
28−import Streamly.Benchmark.Prelude
29+import Streamly.Benchmark.Prelude hiding (sourceUnfoldrMN)
2930
3031import Gauge
3132
@@ -43,11 +44,22 @@ moduleName = "Prelude.ZipSerial"
4344-- Zipping
4445-------------------------------------------------------------------------------
4546
47+-- XXX somehow copying this definition here instead of importing it performs
48+-- better. Need to investigate why.
49+{-# INLINE sourceUnfoldrMN #-}
50+sourceUnfoldrMN :: (S.IsStream t, S.MonadAsync m) => Int -> Int -> t m Int
51+sourceUnfoldrMN count start = S.unfoldrM step start
52+ where
53+ step cnt =
54+ if cnt > start + count
55+ then return Nothing
56+ else return (Just (cnt, cnt + 1))
57+
4658{-# INLINE zip #-}
4759zip :: Int -> Int -> IO ()
4860zip count n =
4961 S.drain $
50− S.zipWith (,) (sourceUnfoldrMN count n) (sourceUnfoldrMN count (n + 1))
62+ S.zipWith (,) (S.serially $ sourceUnfoldrMN count n) (S.serially $ sourceUnfoldrMN count (n + 1))
5163
5264#ifdef INSPECTION
5365inspect $ hasNoTypeClasses 'zip