[Haskell-cafe] Re: Computer time, independent of date
John Goerzen
jgoerzen at complete.org
Fri Jan 9 10:28:49 EST 2009
Steve Schafer wrote:
> On Fri, 09 Jan 2009 11:01:18 -0200, you wrote:
>
>> I'm writing a program that will read medical signs
>>from many patients. It's important to have a precise
>> measure of the time interval between some signs, and
>> that can't depend on adjustments of time. (Supose
>> my software is running midnight at the end of a year
>> with leap seconds. I would get wrong time intervals.)
>
> If you really need that level of accuracy, there is nothing available on
> an off-the-shelf machine that will do the job. You need an independent
> timekeeping source of some kind, one that is not subject to the vagaries
I'm not sure that the original question implied *that* level of need.
Linux has High-Resolution Timers (HRTs) that may be appropriate. See
the manpage for clock_gettime(), which defines these HRTs:
CLOCK_REALTIME
System-wide real-time clock. Setting this clock requires
appropriate privi-
leges.
CLOCK_MONOTONIC
Clock that cannot be set and represents monotonic time
since some unspeci-
fied starting point.
CLOCK_PROCESS_CPUTIME_ID
High-resolution per-process timer from the CPU.
CLOCK_THREAD_CPUTIME_ID
Thread-specific CPU-time clock.
CLOCK_MONOTONIC, in particular, looks suitable. Using it could be a
matter of just a few quick likes in FFI.
I don't know if Windows has similar features.
-- John
More information about the Haskell-Cafe
mailing list