From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA01532 for caml-redistribution; Fri, 20 Feb 1998 11:08:42 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA27259; Thu, 19 Feb 1998 18:27:45 +0100 (MET) 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 SAA27253 for ; Thu, 19 Feb 1998 18:27:43 +0100 (MET) From: GillesDfnx@mail.dotcom.fr Received: from cosmos.imag.fr (cosmos.imag.fr [147.171.130.1]) by concorde.inria.fr (8.8.7/8.8.5) with ESMTP id SAA00837 for ; Thu, 19 Feb 1998 18:27:43 +0100 (MET) Received: from pogo.imag.fr (22110@pogo.imag.fr [147.171.130.104]) by cosmos.imag.fr (8.8.5/8.8.5) with ESMTP id SAA07001 for ; Thu, 19 Feb 1998 18:27:38 +0100 (MET) Date: Thu, 19 Feb 1998 18:27:38 +0100 (MET) Message-Id: <199802191727.SAA07001@cosmos.imag.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: caml-light mailing list Subject: Re: gestion du temps en Caml ? In-Reply-To: <199802191634.RAA26446@pauillac.inria.fr> References: <01bd3e84$1d6056a0$be7b33c2@berruyer.aurecvideo.fr> <199802191634.RAA26446@pauillac.inria.fr> X-Mailer: VM 6.40 under Emacs 20.2.1 Reply-To: GillesDfnx@mail.dotcom.fr Sender: weis Pour Objective caml et unix : il existe la fonction C clock (3), qui a chaque appel retourne le temps ecoule depuis le dernier appel. For Objective caml and unix : there exists a C function, clock (3), that returns the elapsed time since last call. (* Fichier clock.mli *) external clock : unit -> int = "myclock" /* Fichier clock.c */ #include #include #include value myclock (unit) value unit; { long i; i = clock() / CLOCKS_PER_SEC; /* Number of seconds */ return Val_long (i); } (* Fichier test.ml *) open Clock let rec fibo = function 0 -> 1 | 1 -> 1 | n -> fibo (n - 1) + fibo (n - 2);; let _ = let _ = clock () in let n = fibo 35 in let time = clock () in print_int time ; print_newline () ; n;; (* Fin *) $ make ocamlc -c clock.mli gcc -c -I/usr/lib/ocaml/caml clock.c ocamlc -c test.ml ocamlc -custom -o test unix.cma test.cmo clock.o -cclib -lunix time -f "%e" ./test 14 14.46 $ -- \\/// #use "std.disclaimer" (O O) --------------------------------------------oOo--(_)--oOo-------- Gilles DEFOURNEAUX \ / Automated Deduction Team | ATINF project - LEIBNIZ lab --|-- Grenoble, FRANCE 0 GillesDfnx@mail.dotcom.fr