Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
benchmarking fold/streaming
time 1.493 ms (1.400 ms .. 1.591 ms)
0.978 R² (0.973 R² .. 0.987 R²)
mean 1.365 ms (1.331 ms .. 1.414 ms)
std dev 131.6 μs (100.7 μs .. 169.4 μs)
variance introduced by outliers: 69% (severely inflated)
benchmarking fold/conduit
time 3.539 ms (3.431 ms .. 3.663 ms)
0.991 R² (0.985 R² .. 0.995 R²)
mean 3.564 ms (3.500 ms .. 3.652 ms)
std dev 230.4 μs (176.5 μs .. 289.8 μs)
variance introduced by outliers: 43% (moderately inflated)
benchmarking fold/pipes
time 1.078 ms (1.068 ms .. 1.091 ms)
0.998 R² (0.997 R² .. 0.999 R²)
mean 1.104 ms (1.092 ms .. 1.120 ms)
std dev 48.94 μs (39.43 μs .. 62.96 μs)
variance introduced by outliers: 33% (moderately inflated)
benchmarking fold/machines
time 1.268 ms (1.236 ms .. 1.314 ms)
0.991 R² (0.987 R² .. 0.996 R²)
mean 1.214 ms (1.193 ms .. 1.242 ms)
std dev 79.28 μs (59.62 μs .. 98.11 μs)
variance introduced by outliers: 52% (severely inflated)
benchmarking fold/freer
time 3.961 ms (3.917 ms .. 4.016 ms)
0.997 R² (0.994 R² .. 0.999 R²)
mean 4.051 ms (4.003 ms .. 4.119 ms)
std dev 162.8 μs (125.9 μs .. 234.9 μs)
variance introduced by outliers: 21% (moderately inflated)
benchmarking fold/list
time 1.320 ms (1.307 ms .. 1.335 ms)
0.999 R² (0.998 R² .. 0.999 R²)
mean 1.329 ms (1.320 ms .. 1.344 ms)
std dev 38.77 μs (29.10 μs .. 57.37 μs)
variance introduced by outliers: 17% (moderately inflated)
benchmarking map/streaming
time 1.576 ms (1.558 ms .. 1.593 ms)
0.999 R² (0.999 R² .. 0.999 R²)
mean 1.577 ms (1.567 ms .. 1.589 ms)
std dev 37.51 μs (31.12 μs .. 47.11 μs)
variance introduced by outliers: 12% (moderately inflated)
benchmarking map/conduit
time 4.350 ms (4.316 ms .. 4.384 ms)
0.999 R² (0.999 R² .. 1.000 R²)
mean 4.323 ms (4.292 ms .. 4.353 ms)
std dev 97.85 μs (70.05 μs .. 140.1 μs)
benchmarking map/pipes
time 3.728 ms (3.678 ms .. 3.770 ms)
0.999 R² (0.998 R² .. 0.999 R²)
mean 3.719 ms (3.692 ms .. 3.746 ms)
std dev 88.12 μs (76.41 μs .. 105.3 μs)
variance introduced by outliers: 10% (moderately inflated)
benchmarking map/machines
time 4.659 ms (4.597 ms .. 4.736 ms)
0.998 R² (0.997 R² .. 1.000 R²)
mean 4.622 ms (4.589 ms .. 4.657 ms)
std dev 106.9 μs (83.23 μs .. 133.7 μs)
benchmarking drop/streaming
time 685.8 μs (681.7 μs .. 689.3 μs)
1.000 R² (0.999 R² .. 1.000 R²)
mean 682.4 μs (678.0 μs .. 686.6 μs)
std dev 14.12 μs (10.84 μs .. 19.35 μs)
variance introduced by outliers: 11% (moderately inflated)
benchmarking drop/conduit
time 2.799 ms (2.768 ms .. 2.825 ms)
0.999 R² (0.998 R² .. 0.999 R²)
mean 2.766 ms (2.734 ms .. 2.794 ms)
std dev 100.1 μs (82.81 μs .. 124.4 μs)
variance introduced by outliers: 20% (moderately inflated)
benchmarking drop/pipes
time 3.203 ms (3.167 ms .. 3.233 ms)
0.999 R² (0.998 R² .. 0.999 R²)
mean 3.190 ms (3.161 ms .. 3.212 ms)
std dev 80.54 μs (64.09 μs .. 117.3 μs)
variance introduced by outliers: 11% (moderately inflated)
benchmarking drop/freer
time 3.501 ms (3.473 ms .. 3.529 ms)
0.999 R² (0.999 R² .. 1.000 R²)
mean 3.527 ms (3.503 ms .. 3.557 ms)
std dev 85.32 μs (67.30 μs .. 114.3 μs)
benchmarking drop/machines
time 2.038 ms (2.015 ms .. 2.058 ms)
0.999 R² (0.998 R² .. 0.999 R²)
mean 2.015 ms (1.998 ms .. 2.037 ms)
std dev 63.46 μs (52.94 μs .. 78.15 μs)
variance introduced by outliers: 18% (moderately inflated)
benchmarking dropWhile/streaming
time 809.7 μs (800.1 μs .. 820.5 μs)
0.999 R² (0.998 R² .. 1.000 R²)
mean 803.8 μs (798.6 μs .. 809.7 μs)
std dev 18.97 μs (15.81 μs .. 23.56 μs)
variance introduced by outliers: 14% (moderately inflated)
benchmarking dropWhile/conduit
time 2.808 ms (2.775 ms .. 2.843 ms)
0.999 R² (0.998 R² .. 0.999 R²)
mean 2.805 ms (2.781 ms .. 2.830 ms)
std dev 83.53 μs (67.56 μs .. 103.8 μs)
variance introduced by outliers: 15% (moderately inflated)
benchmarking dropWhile/pipes
time 2.844 ms (2.814 ms .. 2.879 ms)
0.999 R² (0.998 R² .. 0.999 R²)
mean 2.870 ms (2.852 ms .. 2.892 ms)
std dev 67.17 μs (54.91 μs .. 93.12 μs)
benchmarking dropWhile/machines
time 4.047 ms (4.007 ms .. 4.091 ms)
0.999 R² (0.999 R² .. 1.000 R²)
mean 4.060 ms (4.029 ms .. 4.096 ms)
std dev 102.3 μs (79.64 μs .. 151.8 μs)
variance introduced by outliers: 10% (moderately inflated)
benchmarking scan/streaming
time 3.149 ms (3.051 ms .. 3.272 ms)
0.996 R² (0.992 R² .. 0.999 R²)
mean 3.080 ms (3.055 ms .. 3.116 ms)
std dev 93.51 μs (63.11 μs .. 152.5 μs)
variance introduced by outliers: 15% (moderately inflated)
benchmarking scan/conduit
time 7.352 ms (7.204 ms .. 7.524 ms)
0.997 R² (0.994 R² .. 0.999 R²)
mean 7.353 ms (7.277 ms .. 7.479 ms)
std dev 275.2 μs (176.3 μs .. 429.7 μs)
variance introduced by outliers: 16% (moderately inflated)
benchmarking scan/pipes
time 4.659 ms (4.591 ms .. 4.735 ms)
0.998 R² (0.997 R² .. 0.999 R²)
mean 4.708 ms (4.660 ms .. 4.756 ms)
std dev 145.5 μs (118.7 μs .. 180.1 μs)
variance introduced by outliers: 13% (moderately inflated)
benchmarking scan/machines
time 10.06 ms (9.959 ms .. 10.17 ms)
0.999 R² (0.999 R² .. 1.000 R²)
mean 10.11 ms (10.06 ms .. 10.18 ms)
std dev 169.7 μs (132.3 μs .. 215.7 μs)
benchmarking take/streaming
time 1.460 ms (1.443 ms .. 1.480 ms)
0.999 R² (0.998 R² .. 0.999 R²)
mean 1.477 ms (1.465 ms .. 1.491 ms)
std dev 45.14 μs (36.82 μs .. 55.18 μs)
variance introduced by outliers: 18% (moderately inflated)
benchmarking take/conduit
time 5.885 ms (5.605 ms .. 6.119 ms)
0.991 R² (0.986 R² .. 0.997 R²)
mean 5.589 ms (5.522 ms .. 5.684 ms)
std dev 247.7 μs (172.2 μs .. 343.5 μs)
variance introduced by outliers: 22% (moderately inflated)
benchmarking take/pipes
time 3.757 ms (3.664 ms .. 3.877 ms)
0.995 R² (0.992 R² .. 0.997 R²)
mean 4.030 ms (3.948 ms .. 4.148 ms)
std dev 305.7 μs (230.3 μs .. 410.7 μs)
variance introduced by outliers: 50% (moderately inflated)
benchmarking take/machines
time 4.794 ms (4.729 ms .. 4.858 ms)
0.999 R² (0.998 R² .. 0.999 R²)
mean 4.804 ms (4.767 ms .. 4.840 ms)
std dev 116.0 μs (91.21 μs .. 160.0 μs)
benchmarking takeWhile/streaming
time 1.542 ms (1.518 ms .. 1.566 ms)
0.999 R² (0.998 R² .. 0.999 R²)
mean 1.549 ms (1.535 ms .. 1.563 ms)
std dev 48.44 μs (39.99 μs .. 60.66 μs)
variance introduced by outliers: 18% (moderately inflated)
benchmarking takeWhile/conduit
time 5.071 ms (4.988 ms .. 5.209 ms)
0.993 R² (0.982 R² .. 0.999 R²)
mean 5.042 ms (4.988 ms .. 5.173 ms)
std dev 241.2 μs (139.5 μs .. 425.6 μs)
variance introduced by outliers: 26% (moderately inflated)
benchmarking takeWhile/pipes
time 3.775 ms (3.723 ms .. 3.850 ms)
0.998 R² (0.996 R² .. 0.999 R²)
mean 3.767 ms (3.740 ms .. 3.801 ms)
std dev 94.85 μs (72.88 μs .. 152.4 μs)
variance introduced by outliers: 10% (moderately inflated)
benchmarking takeWhile/machines
time 4.600 ms (4.529 ms .. 4.713 ms)
0.994 R² (0.981 R² .. 0.999 R²)
mean 4.493 ms (4.448 ms .. 4.597 ms)
std dev 210.8 μs (112.3 μs .. 428.7 μs)
variance introduced by outliers: 27% (moderately inflated)
module Main (main) where
import Criterion.Main
import qualified Data.Conduit as C
import qualified Data.Conduit.Combinators as CC
import qualified Data.Conduit.List as C
import qualified Data.Machine as M
import qualified Data.Machine.Runner as M
import qualified Pipes as P
import qualified Pipes.Prelude as P
import qualified Streaming.Prelude as S
import Streaming (Of (..))
import Streaming.Internal (Stream(..))
import qualified Streaming.Internal as I
import qualified Streaming as S
import qualified System.IO.Streams as Streams
import Data.List (foldl')
import Control.Monad (void)
import Control.Monad.Identity
main :: IO ()
main =
defaultMain
[ bgroup "fold"
[ bench "list" $ whnf (foldl' (+) 0. ($())) sourceL
, bench "streaming" $ whnf (runIdentity . S.fold (+) 0 id . ($())) ( sourceS)
, bench "conduit" $ whnf (runIdentity . (C.$$ CC.foldl (+) 0) . ($())) sourceC
, bench "pipes" $ whnf (runIdentity . P.fold (+) 0 id . ($())) sourceP
, bench "machines" $ whnf (runIdentity . M.foldlT (+) 0 . ($())) sourceM
]
, bgroup "map"
[ bench "streaming" $ whnf (runIdentity . drainS) (S.map (+1))
, bench "conduit" $ whnf ((runIdentity . drainC)) (C.map (+1))
, bench "pipes" $ whnf (runIdentity . drainP) (P.map (+1))
, bench "machines" $ whnf (runIdentity . drainM) (M.auto (+1))
]
, bgroup "drop"
[ bench "streaming" $ whnf (runIdentity . drainS) (S.drop value)
, bench "conduit" $ whnf (runIdentity . drainC) (C.drop value)
, bench "pipes" $ whnf (runIdentity . drainP) (P.drop value)
, bench "machines" $ whnf (runIdentity . drainM) (M.dropping value)
]
, bgroup "dropWhile"
[ bench "streaming" $ whnf (runIdentity . drainS) (S.dropWhile (<= value))
, bench "conduit" $ whnf (runIdentity . drainC) (CC.dropWhile (<= value))
, bench "pipes" $ whnf (runIdentity . drainP) (P.dropWhile (<= value))
, bench "machines" $ whnf (runIdentity . drainM) (M.droppingWhile (<= value))
]
, bgroup "scan"
[ bench "streaming" $ whnf (runIdentity . drainS) (S.scan (+) 0 id)
, bench "conduit" $ whnf (runIdentity . drainC) (CC.scanl (+) 0)
, bench "pipes" $ whnf (runIdentity . drainP) (P.scan (+) 0 id)
, bench "machines" $ whnf (runIdentity . drainM) (M.scan (+) 0)
]
, bgroup "take"
[ bench "streaming" $ whnf (runIdentity . drainS) (S.take value)
, bench "conduit" $ whnf (runIdentity . drainC) (C.isolate value)
, bench "pipes" $ whnf (runIdentity . drainP) (P.take value)
, bench "machines" $ whnf (runIdentity . drainM) (M.taking value)
]
, bgroup "takeWhile"
[ bench "streaming" $ whnf (runIdentity . drainS) (S.takeWhile (<= value))
, bench "conduit" $ whnf (runIdentity . drainC) (CC.takeWhile (<= value) C.=$= C.sinkNull)
, bench "pipes" $ whnf (runIdentity . drainP) (P.takeWhile (<= value))
, bench "machines" $ whnf (runIdentity . drainM) (M.takingWhile (<= value))
]
]
value :: Int
value = 100000
drainS p = S.effects (p (sourceS ()) )
-- drainM :: M.ProcessT Identity Int o -> ()
drainM m = M.runT_ (sourceM () M.~> m)
-- drainP :: P.Proxy () Int () a Identity () -> ()
drainP p = P.runEffect $ P.for (sourceP () P.>-> p) P.discard
-- drainC :: C.Conduit Int Identity a -> ()
drainC c = (sourceC () C.$= c) C.$$ C.sinkNull
-- drainSC :: C.Sink Int Identity b -> b
drainSC c = sourceC () C.$$ c
sourceM () = M.enumerateFromTo 1 value
sourceC () = C.sourceList [1..value]
sourceP () = P.each [1..value]
sourceS () = S.each [1..value] -- take value $ S.enumFrom 1
sourceL () = [1..value]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment