Hello Mirko,
Friday, May 12, 2006, 4:42:02 PM, you wrote:
>> PS: I am still curious: does threadDelay use
>> the wall clock or the per-process clock (CPU time)?
> I think it uses wall clock time. Proof:
>> And regardless of the answer - how could one obtain
>> the opposite behaviour? (I don't find this discussed
>> in the visible docs. Or am I missing something?)
use threadDelay in cycle, testing CPU time each time. the following
code used by me to measure both wall and CPU time. but i should say
that cpu time measurement sometimes gives negative results :) i think
it may be because it returns time for CURRENT OS thread, but Haskell
runtime sometimes creates new OS thread and continue execute Haskell
code in this new created thread (at least under Windows)
benchmark h str times action = do
prev <- getCPUTime
prev2 <- getClockTime
action
current <- getCPUTime
current2 <- getClockTime
let secs = fromIntegral (current-prev) / 1e12
secs2 = diffTimes current2 prev2
putStrLn$ str ++ ": " ++ showTime secs2 ++ " (user: " ++ showTime secs ++
")"
showTime secs = showFFloat (Just 3) secs " secs"
diffTimes (TOD sa pa) (TOD sb pb) = i(sa - sb) + (i(pa-pb) / 1e12)
i x = fromIntegral x
--
Best regards,
Bulat mailto:[EMAIL PROTECTED]
_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell