mirror of
https://github.com/composewell/streamly.git
synced 2024-11-13 11:05:23 +03:00
Move additional benchmarks under a build flag
This commit is contained in:
parent
deec84bbee
commit
53b8da31af
@ -63,6 +63,11 @@ test-suite test
|
||||
transformers >= 0.4 && < 0.6
|
||||
default-language: Haskell2010
|
||||
|
||||
flag extra-benchmarks
|
||||
description: Include comparative benchmarks
|
||||
manual: True
|
||||
default: False
|
||||
|
||||
benchmark bench
|
||||
type: exitcode-stdio-1.0
|
||||
main-is: Main.hs
|
||||
@ -76,12 +81,20 @@ benchmark bench
|
||||
, atomic-primops >= 0.8 && < 0.9
|
||||
, base >= 4.8 && < 5
|
||||
, criterion >= 1 && < 2
|
||||
, list-t >= 1 && < 2
|
||||
, logict >= 0.6 && < 0.7
|
||||
, machines >= 0.6 && < 0.7
|
||||
, mtl >= 2.2 && < 3
|
||||
, simple-conduit >= 0.6 && < 0.7
|
||||
, transient >= 0.4 && < 0.6
|
||||
|
||||
if impl(ghc < 8.0)
|
||||
build-depends:
|
||||
transformers >= 0.4 && < 0.6
|
||||
|
||||
if flag(extra-benchmarks)
|
||||
cpp-options: -DEXTRA_BENCHMARKS
|
||||
build-depends:
|
||||
list-t >= 0.4 && < 2
|
||||
, logict >= 0.6 && < 0.7
|
||||
, machines >= 0.5 && < 0.7
|
||||
, simple-conduit >= 0.6 && < 0.7
|
||||
, transient >= 0.4 && < 0.6
|
||||
default-language: Haskell2010
|
||||
|
||||
source-repository head
|
||||
|
@ -12,6 +12,8 @@ import Data.IORef (IORef, newIORef, writeIORef)
|
||||
import System.IO.Unsafe (unsafePerformIO)
|
||||
|
||||
import qualified Asyncly as A
|
||||
|
||||
#ifdef EXTRA_BENCHMARKS
|
||||
import qualified Conduit.Simple as S
|
||||
import qualified Control.Monad.Logic as LG
|
||||
import qualified Data.Machine as M
|
||||
@ -20,6 +22,7 @@ import qualified Transient.Internals as T
|
||||
import qualified Transient.Indeterminism as T
|
||||
#endif
|
||||
import qualified ListT as LT
|
||||
#endif
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
@ -33,6 +36,7 @@ main = do
|
||||
, bench "asyncly-interleaved-nil" $ nfIO (asyncly_nil (A.<=>))
|
||||
, bench "asyncly-parleft-nil" $ nfIO (asyncly_nil (A.<|))
|
||||
, bench "asyncly-parinterleaved-nil" $ nfIO (asyncly_nil (A.<|>))
|
||||
#ifdef EXTRA_BENCHMARKS
|
||||
#if MIN_VERSION_transient(0,5,1)
|
||||
, bench "transient" $ nfIO transient_basic
|
||||
, bench "transient-nil" $ nfIO transient_nil
|
||||
@ -41,6 +45,7 @@ main = do
|
||||
, bench "list-t" $ nfIO list_t_basic
|
||||
, bench "simple-conduit" $ nfIO simple_conduit_basic
|
||||
, bench "machines" $ nfIO machines_basic
|
||||
#endif
|
||||
]
|
||||
]
|
||||
|
||||
@ -64,39 +69,6 @@ drop num x = do
|
||||
guard mn
|
||||
return x
|
||||
|
||||
#if MIN_VERSION_transient(0,5,1)
|
||||
tmap :: (a -> Int) -> a -> T.TransIO Int
|
||||
tmap = Main.map
|
||||
|
||||
tfilter :: (a -> Bool) -> a -> T.TransIO a
|
||||
tfilter = Main.filter
|
||||
|
||||
tdrop :: Int -> Int -> T.TransIO Int
|
||||
tdrop = Main.drop
|
||||
|
||||
transient_basic :: IO (Maybe Int)
|
||||
|
||||
transient_basic = T.keep' $ T.threads 0 $ do
|
||||
liftIO $ writeIORef count 0
|
||||
xs <- T.group 49900 $ do
|
||||
T.choose [1..100000 :: Int]
|
||||
>>= tfilter even
|
||||
>>= tmap (+1)
|
||||
>>= tdrop 100
|
||||
>>= tmap (+1)
|
||||
>>= tfilter (\x -> x `mod` 2 == 0)
|
||||
|
||||
assert (Prelude.length xs == 49900) $
|
||||
T.exit (Prelude.length xs)
|
||||
|
||||
transient_nil :: IO (Maybe Int)
|
||||
transient_nil = T.keep' $ T.threads 0 $ do
|
||||
xs <- T.group 49900 $ do
|
||||
T.choose [1..100000 :: Int]
|
||||
assert (Prelude.length xs == 49900) $
|
||||
T.exit (Prelude.length xs)
|
||||
#endif
|
||||
|
||||
amap :: (Int -> Int) -> Int -> A.AsyncT IO Int
|
||||
amap = Main.map
|
||||
|
||||
@ -132,6 +104,40 @@ asyncly_nil f = do
|
||||
assert (Prelude.length xs == 100000) $
|
||||
return (Prelude.length xs)
|
||||
|
||||
#ifdef EXTRA_BENCHMARKS
|
||||
#if MIN_VERSION_transient(0,5,1)
|
||||
tmap :: (a -> Int) -> a -> T.TransIO Int
|
||||
tmap = Main.map
|
||||
|
||||
tfilter :: (a -> Bool) -> a -> T.TransIO a
|
||||
tfilter = Main.filter
|
||||
|
||||
tdrop :: Int -> Int -> T.TransIO Int
|
||||
tdrop = Main.drop
|
||||
|
||||
transient_basic :: IO (Maybe Int)
|
||||
|
||||
transient_basic = T.keep' $ T.threads 0 $ do
|
||||
liftIO $ writeIORef count 0
|
||||
xs <- T.group 49900 $ do
|
||||
T.choose [1..100000 :: Int]
|
||||
>>= tfilter even
|
||||
>>= tmap (+1)
|
||||
>>= tdrop 100
|
||||
>>= tmap (+1)
|
||||
>>= tfilter (\x -> x `mod` 2 == 0)
|
||||
|
||||
assert (Prelude.length xs == 49900) $
|
||||
T.exit (Prelude.length xs)
|
||||
|
||||
transient_nil :: IO (Maybe Int)
|
||||
transient_nil = T.keep' $ T.threads 0 $ do
|
||||
xs <- T.group 49900 $ do
|
||||
T.choose [1..100000 :: Int]
|
||||
assert (Prelude.length xs == 49900) $
|
||||
T.exit (Prelude.length xs)
|
||||
#endif
|
||||
|
||||
lfilter :: (Int -> Bool) -> Int -> LT.ListT IO Int
|
||||
lfilter = Main.filter
|
||||
|
||||
@ -199,3 +205,4 @@ machines_basic = do
|
||||
M.~> M.filtered (\x -> x `mod` 2 == 0)
|
||||
assert (Prelude.length xs == 49900) $
|
||||
return (Prelude.length (xs ::[Int]))
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user