Skip to content

Instantly share code, notes, and snippets.

@aycanirican
Created June 2, 2010 23:35
Show Gist options
  • Save aycanirican/423182 to your computer and use it in GitHub Desktop.
Save aycanirican/423182 to your computer and use it in GitHub Desktop.
threadDelay :: Int -> IO () Source
Suspends the current thread for a given number of microseconds (GHC only).
There is no guarantee that the thread will be rescheduled promptly when the delay has expired, but the thread will ***never continue to run earlier than specified***.
---
module Main where
import Criterion.Main
import Control.Concurrent
sleep1 = do
threadDelay 1000000
return ()
main :: IO ()
main = defaultMain [bench "1 sec delay" $ whnfIO sleep1 ]
---
warming up
estimating clock resolution...
mean is 9.540081 us (80001 iterations)
found 1384 outliers among 79997 samples (1.7%)
1221 (1.5%) high severe
estimating cost of a clock call...
mean is 193.1040 ns (62 iterations)
found 4 outliers among 62 samples (6.5%)
1 (1.6%) low severe
1 (1.6%) low mild
2 (3.2%) high severe
benchmarking 1 sec delay
collecting 100 samples, 1 iterations each, in estimated 100.1319 s
bootstrapping with 100000 resamples
mean: 1.001000 s, lb 1.000953 s, ub 1.001030 s, ci 0.950
std dev: 192.3861 us, lb 131.5291 us, ub 265.3644 us, ci 0.950
found 14 outliers among 100 samples (14.0%)
10 (10.0%) low severe
3 (3.0%) high mild
1 (1.0%) high severe
variance introduced by outliers: 0.990%
variance is unaffected by outliers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment