cpuTimePrecision wrong on Windows?

Hello folks, One odd thing I noticed is that the cpuTimePrecision on Windows seems to be "hardwired" in the source code to 1000000000. I don't know if this is supposed to be the same on all windows platforms or if it depends on hardware, but it seems to be wrong on my machine. At least getCPUTime always seems to return a multiple of 125000000 (1/8 of cpuTimePrecision). Regards -- Adrian Hey

Adrian Hey wrote:
At least getCPUTime always seems to return a multiple of 125000000 (1/8 of cpuTimePrecision).
Actually, that's wrong. A little more intelligent experimentation reveals that (on my system at least) getCPUTime always returns a multiple of 15625000000 (cpuTimePrecision = 15.625 mS IOW). It's still not the same as the figure exported by System.CPUTime though :-( Regards -- Adrian Hey

Both numbers seem odd to me.
As far as I can tell, GHC uses GetProcessTimes to implement
getCPUTime. GetProcessTimes returns counts of 100s of nanoseconds,
which isn't the number GHC uses for cpuTimePrecision, but I can't find
anyplace in the API documentation that Microsoft actually guarantees
any non-hardware dependent timing precision.
/g
On Wed, Feb 20, 2008 at 2:46 AM, Adrian Hey
Adrian Hey wrote:
At least getCPUTime always seems to return a multiple of 125000000 (1/8 of cpuTimePrecision).
Actually, that's wrong. A little more intelligent experimentation reveals that (on my system at least) getCPUTime always returns a multiple of 15625000000 (cpuTimePrecision = 15.625 mS IOW).
It's still not the same as the figure exported by System.CPUTime though :-(
Regards -- Adrian Hey
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
-- The man who'd introduced them didn't much like either of them, though he acted as if he did, anxious as he was to preserve good relations at all times. One never knew, after all, now did one now did one now did one.

Hello, I wonder (if there's no set reliable figure for all platforms) if it should be done empirically. Here's a naive way.. cpuTimePrecision = unsafePerformIO getCpuTimePrecision getCpuTimePrecision = do t0 <- getCPUTime let wait = do t1 <- getCPUTime if t1>t0 then return (t1-t0) else wait wait But I guess you could do better than that with some more care and effort. Regards -- Adrian Hey
participants (2)
-
Adrian Hey
-
J. Garrett Morris