Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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);
  result


--
Martin Jambon
http://martin.jambon.free.fr