Skip to content

Commit

Permalink
#751, add a benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
ndmitchell committed May 23, 2020
1 parent 1e7bd83 commit 74a0b6f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Test/Pool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import General.Pool
import Control.Concurrent.Extra
import Control.Exception.Extra
import Control.Monad
import System.Time.Extra
import Data.Either.Extra
import General.Timing


main = testSimple $ do
Expand Down Expand Up @@ -92,3 +94,12 @@ main = testSimple $ do
add pool $ try_ $ (do signalBarrier started (); sleep 10) `finally` (do sleep 1; writeVar var True)
add pool $ do waitBarrier started; throw Overflow
(=== True) =<< readVar var

-- benchmark for testing thread performance, see https://github.com/ndmitchell/shake/pull/751
when False $ do
resetTimings
withNumCapabilities 4 $ do
(d, _) <- duration $ runPool False 4 $ \pool -> do
replicateM_ 200000 $ addPool PoolStart pool $ return ()
print d
print =<< getTimings

0 comments on commit 74a0b6f

Please sign in to comment.