time bug

Matthew Fluet fluet@CS.Cornell.EDU
Mon, 26 Mar 2001 16:34:54 -0500 (EST)


Steve, I'm also curious if you were able to recreate the bug on your
system with the mlton-20010321 version and the timeBug{1,2}.sml files.

> I changed Posix.ProcEnv.times in the same way as I did currentTime so that it
> uses CLK_TCK.
> 
> 	 val ticksPerSecond: LargeInt.int =
> 	    SysWord.toLargeInt (sysconf "CLK_TCK")
> 
> 	 val millisecondsPerSecond: LargeInt.int = 1000
> 	    
> 	 fun cvt (ticks: int): Time.time =
> 	    Time.fromMilliseconds
> 	    (LargeInt.div
> 	     (LargeInt.fromInt ticks * millisecondsPerSecond,
> 	      ticksPerSecond))
> 
> Given this fix, I don't think there can be any rounding error (and hence
> discrepancies) as long as the number of ticks per millisecond is an integer.

Which it will be, because CLK_TCK = 100.