From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 04FE0BB91 for ; Tue, 14 Dec 2004 22:53:08 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iBELr6Sm014911 for ; Tue, 14 Dec 2004 22:53:06 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA07872 for ; Tue, 14 Dec 2004 22:53:05 +0100 (MET) Received: from will.iki.fi (will.iki.fi [217.169.64.20]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iBELr5ko014907 for ; Tue, 14 Dec 2004 22:53:05 +0100 Received: from ZMCXXXIII.dsl.saunalahti.fi (ZMCXXXIII.dsl.saunalahti.fi [85.76.70.234]) by will.iki.fi (Postfix) with ESMTP id BD2AF139; Tue, 14 Dec 2004 23:53:00 +0200 (EET) Subject: Re: [Caml-list] Simple clock From: Ville-Pertti Keinonen To: romildo@uber.com.br Cc: Lars Nilsson , caml-list@inria.fr In-Reply-To: <20041214203930.GA26559@gentoo.malaquias.no-ip.org> References: <20041214171716.GA10373@gentoo.malaquias.no-ip.org> <4d029f7e04121410172361f47a@mail.gmail.com> <20041214203930.GA26559@gentoo.malaquias.no-ip.org> Content-Type: text/plain Date: Tue, 14 Dec 2004 23:52:51 +0200 Message-Id: <1103061171.74797.23.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.0.3 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41BF60C2.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41BF60C1.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 romildo:01 wrote:01 gettimeofday:01 gettimeofday:01 unix:01 unix:01 newline:02 probably:05 it'll:05 it'll:05 tue:06 fst:06 fst:06 intervals:06 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: 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.