Browse thread
Simple clock
-
romildo@u...
-
Keith Wansbrough
-
Lars Nilsson
-
romildo@u...
- Ville-Pertti Keinonen
- Kurt Welgehausen
-
romildo@u...
- romildo@u...
-
Lars Nilsson
-
Keith Wansbrough
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Ville-Pertti Keinonen <will@e...> |
| Subject: | Re: [Caml-list] Simple clock |
On Tue, 2004-12-14 at 18:39 -0200, romildo@uber.com.br wrote: > Particularly, the while, print_tm and print_newline execution > time is not counted. Would that introduce an accurace in > my clock? If so, is that inevitable? It'll always print the correct time, at approximately one-second intervals, but as you suspect, it'll drift over time. What you probably want for the delay is something like: ignore (Unix.select [] [] [] (1.0 -. (fst (modf (Unix.gettimeofday ()))))) Unix.gettimeofday () returns the time as a floating point number with reasonable accuracy, modf splits it into fractional and integral parts, fst selects the first one (the fractional part), so the select returns at (or as close to as possible) the next integral second.