English version
Accueil     Ŕ propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis ŕ jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml ŕ l'adresse ocaml.org.

Browse thread
Tools for execution timing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-02-27 (18:49)
From: Martin Jambon <martin.jambon@e...>
Subject: Re: [Caml-list] Tools for execution timing
On Tue, 27 Feb 2007, Denis Bueno wrote:

> Dear list,
> Just a general request (Caml Hump & Google didn't find anything,
> really): what do people use to time executions? I want to time the
> execution of various phases of a compiler I'm writing, in order to get
> an idea of how relatively efficient they are.
> Would you recommend I just roll my own? Or is there something written
> & debugged I could use?

You could use that:

let time msg f x =
  let t1 = Unix.gettimeofday () in
  let result = f x in
  let t2 = Unix.gettimeofday () in
  Printf.printf "%s: %.3f s\n%!" msg (t2 -. t1);

Martin Jambon