@@ -1216,7 +1216,7 @@ iterateSource ::
1218 -> SerialT m Int
1218 -> SerialT m Int
1219−iterateSource g i n = f i (sourceUnfoldrMN iterStreamLen n)
1219+iterateSource g i n = f i (sourceUnfoldrM iterStreamLen n)
1221 f (0 :: Int) m = g m
1221 f (0 :: Int) m = g m
1222 f x m = g (f (x P.- 1) m)
1222 f x m = g (f (x P.- 1) m)
@@ -1324,23 +1324,23 @@ o_1_space_pipesX4 value =
1324serial2 :: Int -> Int -> IO ()
1324serial2 :: Int -> Int -> IO ()
1325serial2 count n =
1325serial2 count n =
1326 S.drain $
1326 S.drain $
1327− S.serial (sourceUnfoldrMN count n) (sourceUnfoldrMN count (n + 1))
1327+ S.serial (sourceUnfoldrM count n) (sourceUnfoldrM count (n + 1))
1329{-# INLINE serial4 #-}
1329{-# INLINE serial4 #-}
1330serial4 :: Int -> Int -> IO ()
1330serial4 :: Int -> Int -> IO ()
1331serial4 count n =
1331serial4 count n =
1332 S.drain $
1332 S.drain $
1333 S.serial
1333 S.serial
1334− (S.serial (sourceUnfoldrMN count n) (sourceUnfoldrMN count (n + 1)))
1334+ (S.serial (sourceUnfoldrM count n) (sourceUnfoldrM count (n + 1)))
1335 (S.serial
1335 (S.serial
1336− (sourceUnfoldrMN count (n + 2))
1336+ (sourceUnfoldrM count (n + 2))
1337− (sourceUnfoldrMN count (n + 3)))
1337+ (sourceUnfoldrM count (n + 3)))
1339{-# INLINE append2 #-}
1339{-# INLINE append2 #-}
1340append2 :: Int -> Int -> IO ()
1340append2 :: Int -> Int -> IO ()
1341append2 count n =
1341append2 count n =
1342 S.drain $
1342 S.drain $
1343− Internal.append (sourceUnfoldrMN count n) (sourceUnfoldrMN count (n + 1))
1343+ Internal.append (sourceUnfoldrM count n) (sourceUnfoldrM count (n + 1))
1345{-# INLINE append4 #-}
1345{-# INLINE append4 #-}
1346append4 :: Int -> Int -> IO ()
1346append4 :: Int -> Int -> IO ()
@@ -1348,11 +1348,11 @@ append4 count n =
1348 S.drain $
1348 S.drain $
1349 Internal.append
1349 Internal.append
1350 (Internal.append
1350 (Internal.append
1351− (sourceUnfoldrMN count n)
1351+ (sourceUnfoldrM count n)
1352− (sourceUnfoldrMN count (n + 1)))
1352+ (sourceUnfoldrM count (n + 1)))
1353 (Internal.append
1353 (Internal.append
1354− (sourceUnfoldrMN count (n + 2))
1354+ (sourceUnfoldrM count (n + 2))
1355− (sourceUnfoldrMN count (n + 3)))
1355+ (sourceUnfoldrM count (n + 3)))
1357#ifdef INSPECTION
1357#ifdef INSPECTION
1358inspect $ hasNoTypeClasses 'append2
1358inspect $ hasNoTypeClasses 'append2
@@ -1370,8 +1370,8 @@ mergeBy count n =
1370 S.drain $
1370 S.drain $
1371 S.mergeBy
1371 S.mergeBy
1372 P.compare
1372 P.compare
1373− (sourceUnfoldrMN count n)
1373+ (sourceUnfoldrM count n)
1374− (sourceUnfoldrMN count (n + 1))
1374+ (sourceUnfoldrM count (n + 1))
1376#ifdef INSPECTION
1376#ifdef INSPECTION
1377inspect $ hasNoTypeClasses 'mergeBy
1377inspect $ hasNoTypeClasses 'mergeBy
@@ -1397,10 +1397,13 @@ o_1_space_joining value =
1397o_1_space_concatFoldable :: Int -> [Benchmark]
1397o_1_space_concatFoldable :: Int -> [Benchmark]
1398o_1_space_concatFoldable value =
1398o_1_space_concatFoldable value =
1399 [ bgroup "concat-foldable"
1399 [ bgroup "concat-foldable"
1400− [ benchIOSrc serially "foldMapWith" (sourceFoldMapWith value)
1400+ [ benchIOSrc serially "foldMapWith (<>) (List)"
1401+ (sourceFoldMapWith value)
1402+ , benchIOSrc serially "foldMapWith (<>) (Stream)"
1403+ (sourceFoldMapWithStream value)
1404+ , benchIOSrc serially "foldMapWithM (<>) (List)"
1401− , benchIOSrc serially "foldMapWithM" (sourceFoldMapWithM value)
1405+ (sourceFoldMapWithM value)
1402− , benchIOSrc serially "foldMapM" (sourceFoldMapM value)
1406+ , benchIOSrc serially "foldMapM (List)" (sourceFoldMapM value)
1403− , benchIOSrc serially "foldWithConcatMapId" (sourceConcatMapId value)
@@ -1414,8 +1417,8 @@ o_1_space_concatFoldable value =
1414concatMap :: Int -> Int -> Int -> IO ()
1417concatMap :: Int -> Int -> Int -> IO ()
1415concatMap outer inner n =
1418concatMap outer inner n =
1416 S.drain $ S.concatMap
1419 S.drain $ S.concatMap
1417− (\_ -> sourceUnfoldrMN inner n)
1420+ (\_ -> sourceUnfoldrM inner n)
1418− (sourceUnfoldrMN outer n)
1421+ (sourceUnfoldrM outer n)
1420#ifdef INSPECTION
1423#ifdef INSPECTION
1421inspect $ hasNoTypeClasses 'concatMap
1424inspect $ hasNoTypeClasses 'concatMap
@@ -1428,8 +1431,8 @@ inspect $ 'concatMap `hasNoType` ''SPEC
1428concatMapPure :: Int -> Int -> Int -> IO ()
1431concatMapPure :: Int -> Int -> Int -> IO ()
1429concatMapPure outer inner n =
1432concatMapPure outer inner n =
1430 S.drain $ S.concatMap
1433 S.drain $ S.concatMap
1431− (\_ -> sourceUnfoldrN inner n)
1434+ (\_ -> sourceUnfoldr inner n)
1432− (sourceUnfoldrN outer n)
1435+ (sourceUnfoldr outer n)
1434#ifdef INSPECTION
1437#ifdef INSPECTION
1435inspect $ hasNoTypeClasses 'concatMapPure
1438inspect $ hasNoTypeClasses 'concatMapPure
@@ -1438,14 +1441,14 @@ inspect $ 'concatMapPure `hasNoType` ''SPEC
1439-- concatMap replicate/unfoldrM
1442-- concatMap replicate/unfoldrM
1441−{-# INLINE concatMapRepl4xN #-}
1444+{-# INLINE concatMapRepl #-}
1442−concatMapRepl4xN :: Int -> Int -> IO ()
1445+concatMapRepl :: Int -> Int -> Int -> IO ()
1446+concatMapRepl outer inner n =
1443−concatMapRepl4xN value n = S.drain $ S.concatMap (S.replicate 4)
1447+ S.drain $ S.concatMap (S.replicate inner) (sourceUnfoldrM outer n)
1444− (sourceUnfoldrMN (value `div` 4) n)
1446#ifdef INSPECTION
1449#ifdef INSPECTION
1447−inspect $ hasNoTypeClasses 'concatMapRepl4xN
1450+inspect $ hasNoTypeClasses 'concatMapRepl
1448−inspect $ 'concatMapRepl4xN `hasNoType` ''SPEC
1451+inspect $ 'concatMapRepl `hasNoType` ''SPEC
1451-- concatMapWith
1454-- concatMapWith
@@ -1472,41 +1475,65 @@ inspect $ 'concatMapWithAppend `hasNoType` ''SPEC
1473-- concatUnfold replicate/unfoldrM
1476-- concatUnfold replicate/unfoldrM
1475−{-# INLINE concatUnfoldRepl4xN #-}
1478+{-# INLINE concatUnfoldRepl #-}
1476−concatUnfoldRepl4xN :: Int -> Int -> IO ()
1479+concatUnfoldRepl :: Int -> Int -> Int -> IO ()
1477−concatUnfoldRepl4xN value n =
1480+concatUnfoldRepl outer inner n =
1478− S.drain $ S.concatUnfold
1481+ S.drain $ S.concatUnfold (UF.replicateM inner) (sourceUnfoldrM outer n)
1480− (sourceUnfoldrMN (value `div` 4) n)
1482#ifdef INSPECTION
1483#ifdef INSPECTION
1483−inspect $ hasNoTypeClasses 'concatUnfoldRepl4xN
1484+inspect $ hasNoTypeClasses 'concatUnfoldRepl
1484−inspect $ 'concatUnfoldRepl4xN `hasNoType` ''D.ConcatMapUState
1485+inspect $ 'concatUnfoldRepl `hasNoType` ''D.ConcatMapUState
1485−inspect $ 'concatUnfoldRepl4xN `hasNoType` ''SPEC
1486+inspect $ 'concatUnfoldRepl `hasNoType` ''SPEC
1488o_1_space_concat :: Int -> [Benchmark]
1489o_1_space_concat :: Int -> [Benchmark]
1489−o_1_space_concat value =
1490+o_1_space_concat value = sqrtVal `seq`
1490 [ bgroup "concat"
1491 [ bgroup "concat"
1491− [ benchIOSrc1 "concatMapPure (2,x/2)"
1492+ [ benchIOSrc1 "concatMapPure (n of 1)"
1492− (concatMapPure 2 (value `div` 2))
1493+ (concatMapPure value 1)
1494+ , benchIOSrc1 "concatMapPure (sqrt n of sqrt n)"
1495+ (concatMapPure sqrtVal sqrtVal)
1493− , benchIOSrc1 "concatMap (2,x/2)"
1496+ , benchIOSrc1 "concatMapPure (1 of n)"
1494− (concatMap 2 (value `div` 2))
1497+ (concatMapPure 1 value)
1499+ -- This is for comparison with foldMapWith
1500+ , benchIOSrc serially "concatMapId (n of 1) (fromFoldable)"
1501+ (S.concatMap id . sourceConcatMapId value)
1495− , benchIOSrc1 "concatMap (x/2,2)"
1503+ , benchIOSrc1 "concatMap (n of 1)"
1496− (concatMap (value `div` 2) 2)
1504+ (concatMap value 1)
1505+ , benchIOSrc1 "concatMap (sqrt n of sqrt n)"
1506+ (concatMap sqrtVal sqrtVal)
1497− , benchIOSrc1 "concatMapRepl (x/4,4)"
1507+ , benchIOSrc1 "concatMap (1 of n)"
1498− (concatMapRepl4xN value)
1508+ (concatMap 1 value)
1499− , benchIOSrc1 "concatUnfoldRepl (x/4,4)"
1509+
1500− (concatUnfoldRepl4xN value)
1510+ -- This is for comparison with foldMapWith
1501− , benchIOSrc1 "concatMapWithSerial (2,x/2)"
1511+ , benchIOSrc serially "concatMapWithId (n of 1) (fromFoldable)"
1512+ (S.concatMapWith serial id . sourceConcatMapId value)
1514+ , benchIOSrc1 "concatMapWith (n of 1)"
1502− (concatMapWithSerial 2 (value `div` 2))
1515+ (concatMapWithSerial value 1)
1503− , benchIOSrc1 "concatMapWithSerial (x/2,2)"
1516+ , benchIOSrc1 "concatMapWith (sqrt n of sqrt n)"
1517+ (concatMapWithSerial sqrtVal sqrtVal)
1518+ , benchIOSrc1 "concatMapWith (1 of n)"
1504− (concatMapWithSerial (value `div` 2) 2)
1519+ (concatMapWithSerial 1 value)
1521+ -- quadratic with number of outer streams
1505− , benchIOSrc1 "concatMapWithAppend (2,x/2)"
1522+ , benchIOSrc1 "concatMapWithAppend (2 of n/2)"
1506 (concatMapWithAppend 2 (value `div` 2))
1523 (concatMapWithAppend 2 (value `div` 2))
1525+ -- concatMap vs concatUnfold
1526+ , benchIOSrc1 "concatMapRepl (sqrt n of sqrt n)"
1527+ (concatMapRepl sqrtVal sqrtVal)
1528+ , benchIOSrc1 "concatUnfoldRepl (sqrt n of sqrt n)"
1529+ (concatUnfoldRepl sqrtVal sqrtVal)
1535+ sqrtVal = round $ sqrt (fromIntegral value :: Double)
1510-------------------------------------------------------------------------------
1537-------------------------------------------------------------------------------
1512-------------------------------------------------------------------------------
1539-------------------------------------------------------------------------------