From: GillesDfnx@mail.dotcom.fr
To: caml-light mailing list <caml-light@pauillac.inria.fr>
Subject: Re: gestion du temps en Caml ?
Date: Thu, 19 Feb 1998 18:27:38 +0100 (MET) [thread overview]
Message-ID: <199802191727.SAA07001@cosmos.imag.fr> (raw)
In-Reply-To: <199802191634.RAA26446@pauillac.inria.fr>
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 <stdlib.h>
#include <time.h>
#include <mlvalues.h>
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
next prev parent reply other threads:[~1998-02-20 10:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-02-21 4:49 Berruyer
1998-02-19 16:34 ` Pierre Weis
1998-02-19 17:27 ` GillesDfnx [this message]
1998-02-19 16:44 ` Patrick Loiseleur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199802191727.SAA07001@cosmos.imag.fr \
--to=gillesdfnx@mail.dotcom.fr \
--cc=caml-light@pauillac.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox