Skip to content

Instantly share code, notes, and snippets.

@msullivan
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save msullivan/3bb033d4367ac6af01bc to your computer and use it in GitHub Desktop.

Select an option

Save msullivan/3bb033d4367ac6af01bc to your computer and use it in GitHub Desktop.
let time_execution func =
let start_time = Sys.time () in
let ret = func () in
let end_time = Sys.time () in
end_time -. start_time, ret
(* val time_execution : (unit -> 'a) -> float * 'a *)
let print_stuff () = Printf.printf "hello, world\n"
let compute_stuff () = 10 + 10
let print_time, () = time_execution print_stuff
let compute_time, value = time_execution compute_stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment