logo       

[ ghc-Bugs-715052 ] getCPUTime doesn't work: msg#00008

lang.haskell.glasgow.bugs

Subject: [ ghc-Bugs-715052 ] getCPUTime doesn't work

Bugs item #715052, was opened at 2003-04-03 19:33
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=715052&group_id=8032

Category: Compiler
Group: 5.04.3
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: getCPUTime doesn't work

Initial Comment:

I use GHC5.04.3 on windows XP.
I want to getCPUTime function to get a number used as
a random seed.
The getCPUTime works well in GHCi(always
increasing), but when
compiled by ghc, the return value of getCPUTime is
fixed to two
values.This can be demonstrated by:

import CPUTime
main = do
d<-getCPUTime
print d

&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;Liu Junfeng
&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;liujf2003@xxxxxxxxxxxxxxxxx
&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;&#12288;2003-04-03

----------------------------------------------------------------------

>Comment By: Sigbjorn Finne (sigbjorn)
Date: 2003-04-04 07:33

Message:
Logged In: YES
user_id=232905

This is expected behaviour, as the value returned by
CPUTime.getCPUTime is process-relative.

You probably want to consult Time.getClockTime also when
manufacturing the seed -- here's how (the non-exported)
Random.mkStdRNG is defined:

mkStdRNG :: Integer -> IO StdGen
mkStdRNG o = do
ct <- getCPUTime
(TOD sec _) <- getClockTime
return (createStdGen (sec * 12345 + ct + o))



----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=715052&group_id=8032


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise