I noticed strange behavior with the threadDelay function in GHC.Conc on some of my machines. The following program:
main = do print "start"
threadDelay (1000 * 1000)
print "done"
1 second is required, as expected. On the other hand, this program:
{-
import Control.Concurrent
main = do print "start"
loop 1000
print "done"
where loop :: Int -> IO ()
loop !n =
if n == 0
then return ()
else do threadDelay 1000
loop (n-1)
it takes about 10 seconds to work on my two machines, although on other machines it takes about 1 second, as expected. (I compiled both of the above programs with the '-threaded' flag.) Here is a screenshot from Threadscope showing that there is activity only once every 10 milliseconds:
On the other hand, here is a screenshot from ThreadScope from one of my machines on which the program takes 1 second in total: 
Similar C program:
#include <unistd.h>
#include <stdio.h>
int main() {
int i;
for (i=1; i < 1000; i++) {
printf("%i\n",i);
usleep(1000);
}
return 0;
}
does the right thing, i.e. running "time. / a.out" gives output, for example:
1
2
...
999
real 0m1.080s
user 0m0.000s
sys 0m0.020s
- , , ? ghc 7.2.1 Linux (x86_64) Ubuntu. Ubuntu 10.04.2, 11.04.