Skip to content

Commit 74a0b6f

Browse files
committed
#751, add a benchmark
1 parent 1e7bd83 commit 74a0b6f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/Test/Pool.hs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import General.Pool
77
import Control.Concurrent.Extra
88
import Control.Exception.Extra
99
import Control.Monad
10+
import System.Time.Extra
1011
import Data.Either.Extra
12+
import General.Timing
1113

1214

1315
main = testSimple $ do
@@ -92,3 +94,12 @@ main = testSimple $ do
9294
add pool $ try_ $ (do signalBarrier started (); sleep 10) `finally` (do sleep 1; writeVar var True)
9395
add pool $ do waitBarrier started; throw Overflow
9496
(=== True) =<< readVar var
97+
98+
-- benchmark for testing thread performance, see https://github.com/ndmitchell/shake/pull/751
99+
when False $ do
100+
resetTimings
101+
withNumCapabilities 4 $ do
102+
(d, _) <- duration $ runPool False 4 $ \pool -> do
103+
replicateM_ 200000 $ addPool PoolStart pool $ return ()
104+
print d
105+
print =<< getTimings

0 commit comments

Comments
 (0)