Skip to content

Commit 3677c6a

Browse files
bolt12coot
authored andcommitted
Added 2 new benchmarks
1 parent 8e05156 commit 3677c6a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

io-sim/bench/Main.hs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
module Main (main) where
55

66
import Control.Concurrent.Class.MonadSTM
7-
import Control.Monad (replicateM)
7+
import Control.Monad (replicateM, forever)
88
import Control.Monad.Class.MonadAsync
99
import Control.Monad.Class.MonadFork
1010
import Control.Monad.Class.MonadSay
@@ -67,6 +67,9 @@ prop_timeout_fail = timeout 1 (threadDelay 2)
6767
prop_timeout_succeed :: forall m. MonadTimer m => m (Maybe ())
6868
prop_timeout_succeed = timeout 2 (threadDelay 1)
6969

70+
prop_timeout_race :: forall m. MonadTimer m => m (Maybe ())
71+
prop_timeout_race = timeout 1 (threadDelay 1)
72+
7073

7174
--
7275
-- threads, async
@@ -88,6 +91,13 @@ prop_async n = do
8891
)
8992
traverse_ wait threads
9093

94+
prop_threadDelay_bottleneck :: forall m. (MonadTimer m, MonadSay m)
95+
=> m (Maybe ())
96+
prop_threadDelay_bottleneck =
97+
timeout 1000000 $ do
98+
forever $ do
99+
threadDelay 1
100+
say ""
91101

92102
main :: IO ()
93103
main = defaultMain
@@ -117,6 +127,8 @@ main = defaultMain
117127
whnf id (runSimOrThrow prop_timeout_fail)
118128
, bench "succeed" $
119129
whnf id (runSimOrThrow prop_timeout_succeed)
130+
, bench "race" $
131+
whnf id (runSimOrThrow prop_timeout_race)
120132
]
121133
]
122134
,
@@ -127,6 +139,8 @@ main = defaultMain
127139
whnf id (runSimOrThrow (prop_async n))
128140
, bench "forkIO silent" $
129141
whnf id (runSimOrThrow (prop_threads n))
142+
, bench "threadDelay bottleneck silent" $
143+
whnf id (runSimOrThrow prop_threadDelay_bottleneck)
130144
, bench "async say" $
131145
nf id ( selectTraceEventsSay
132146
$ runSimTrace
@@ -135,6 +149,10 @@ main = defaultMain
135149
nf id ( selectTraceEventsSay
136150
$ runSimTrace
137151
$ prop_threads n)
152+
, bench "threadDelay bottleneck say" $
153+
nf id ( selectTraceEventsSay
154+
$ runSimTrace
155+
$ prop_threadDelay_bottleneck)
138156
]
139157
, env (pure 250) $ \n ->
140158
bgroup "250"

0 commit comments

Comments
 (0)