From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr 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 9A1CBBB83 for ; Tue, 18 Jul 2006 13:59:44 +0200 (CEST) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k6IBxiPx002568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 18 Jul 2006 13:59:44 +0200 Received: from smtp.lri.fr (serveur3-5 [129.175.3.5]) by ext.lri.fr (Postfix) with ESMTP id 091AA202153; Tue, 18 Jul 2006 13:59:44 +0200 (CEST) Received: from pc9-152.lri.fr (pc9-152 [129.175.9.152]) by smtp.lri.fr (Postfix) with ESMTP id F2CD0CED98; Tue, 18 Jul 2006 13:59:41 +0200 (CEST) Received: from filliatr by pc9-152.lri.fr with local (Exim 4.60) (envelope-from ) id 1G2oEo-0006sr-Uk; Tue, 18 Jul 2006 13:59:42 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <17596.52526.904011.898429@pc9-152.lri.fr> Date: Tue, 18 Jul 2006 13:59:42 +0200 To: Julien Michel Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Unix module troubles & Time functions In-Reply-To: <20060718121035.hy7o1wa1cmhus4g0@webmailetu.univ-orleans.fr> References: <20060718121035.hy7o1wa1cmhus4g0@webmailetu.univ-orleans.fr> X-Mailer: VM 7.19 under Emacs 21.4.1 From: Jean-Christophe Filliatre X-Virus-Scanned: by amavisd-new at lri.fr X-Miltered: at concorde with ID 44BCCD30.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; unix:01 filliatre:01 filliatr:01 lri:01 unix:01 utime:01 utime:01 printf:01 printf:01 filliatre:01 lri:01 filliatr:01 writes:01 caml-list:01 michel:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Julien Michel writes: > I would like to measure the time a function spends inside a Caml > program, for performance purpose. > I need a function with an accuracy of at least 1us. > [...] > Or generally speaking, does any other function exists to achieve such a > measurement (accuracy about 1 us) ? To do such a measurement, I'm using the Unix.times function, as follows: ====================================================================== open Unix let utime f x = let u = (times()).tms_utime in let y = f x in let ut = (times()).tms_utime -. u in (y,ut) let print_utime f x = let (y,ut) = utime f x in Printf.printf "user time: %2.2f\n" ut; y ====================================================================== Hope this helps, -- Jean-Christophe Filliātre (http://www.lri.fr/~filliatr)