How to figure out the amount of time my code has taken in ocaml? are there any functions to measure that?
If you want to measure execution time of individual functions, this utility function is helpful in many cases:
let time f x =
let t = Sys.time() in
let fx = f x in
Printf.printf "Execution time: %fs\n" (Sys.time() -. t);
fx
where f
is any function which takes x
as the argument and returns something.