Module Unix.Timer

Timer functions and similar

val elapsed : ('a -> 'b) -> 'a -> 'b * float

(elapsed f x) returns (f x, t), where t is the elapsed wall-clock time in seconds that it took to evaluate (f x).

val timeout : float -> ('a -> 'b) -> 'a -> ('b, float) Stdlib.result

(timeout t f x) evaluates (f x) but interrupts the evaluation if it takes longer than t wall-clock seconds.

The result is Ok (f x) unless evaluation is interrupted, in which case the result is (Error t).