11708Re: "ocaml_beginners":: timer?
- Jan 3, 2010--- In firstname.lastname@example.org, Jon Harrop <jon@...> wrote:
>Yeah. I tend to use something like this:
> On Saturday 02 January 2010 22:42:07 Jamie Morgenstern wrote:
> > Hello;
> > I was wondering if there is a more fine-grained mechanism for timing
> > code's runtime (e.g., Time.start(timer) ... code ... Time.end(timer) that
> > will calculate only the time spent between the start and end calls.
> > I know this exists in ML; hoping similar is here.
> > Thanks!
let time_and_res (thunk:unit -> 'a) : (float * 'a) =
let t = Unix.gettimeofday() in
let r = thunk() in
let t' = Unix.gettimeofday() in
(t' -. t, r)
- << Previous post in topic