
8 Mar
2010
8 Mar
'10
6:57 p.m.
Why oh why doesn't this work as I expect, and what is the simplest fix? speedTest 4 = 44 time :: (Show t) => IO t -> IO t time a = do start <- getCPUTime v <- a end <- getCPUTime let diff = (fromIntegral (end - start)) / (10^12) print v -- WHY DOESNT THIS WORK? ALWAYS PRINTS () .... printf "Computation time: %0.3f sec\n" (diff :: Double) return v main :: IO () main = do args <- getArgs time $ speedTest (read $ head args) `seq` return ()