Loading ...
Sorry, an error occurred while loading the content.

timer?

Expand Messages
  • Jamie Morgenstern
    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
    Message 1 of 3 , Jan 2, 2010
    • 0 Attachment
      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!

      -J


      [Non-text portions of this message have been removed]
    • Jon Harrop
      ... Unix.gettimeofday()? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e
      Message 2 of 3 , Jan 2, 2010
      • 0 Attachment
        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!

        Unix.gettimeofday()?

        --
        Dr Jon Harrop, Flying Frog Consultancy Ltd.
        http://www.ffconsultancy.com/?e
      • markwvh
        ... Yeah. I tend to use something like this: let time_and_res (thunk:unit - a) : (float * a) = let t = Unix.gettimeofday() in let r = thunk() in let t =
        Message 3 of 3 , Jan 3, 2010
        • 0 Attachment
          --- In ocaml_beginners@yahoogroups.com, Jon Harrop <jon@...> wrote:
          >
          > 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!
          >
          > Unix.gettimeofday()?
          >

          Yeah. I tend to use something like this:

          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)

          HTH.
          -m
        Your message has been successfully submitted and would be delivered to recipients shortly.