From ecd5a39a9f9830cd1f9ba61ef66596a1290c3b65 Mon Sep 17 00:00:00 2001 From: theteachr Date: Thu, 23 May 2024 18:50:19 +0530 Subject: [PATCH] Add the convenience fun `Time_ns.since` Signed-off-by: theteachr --- core/src/time_ns.ml | 1 + core/src/time_ns_intf.ml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/core/src/time_ns.ml b/core/src/time_ns.ml index 003e9b4..e1f039e 100644 --- a/core/src/time_ns.ml +++ b/core/src/time_ns.ml @@ -22,6 +22,7 @@ let epoch = Span.zero let add = Span.( + ) let sub = Span.( - ) let diff = Span.( - ) +let since = diff @@ now () let abs_diff t u = Span.abs (diff t u) let max = Span.max let min = Span.min diff --git a/core/src/time_ns_intf.ml b/core/src/time_ns_intf.ml index 89b937b..6568179 100644 --- a/core/src/time_ns_intf.ml +++ b/core/src/time_ns_intf.ml @@ -396,6 +396,9 @@ module type Time_ns = sig (** overflows silently *) val diff : t -> t -> Span.t + (** overflows silently *) + val since : t -> Span.t + (** overflows silently *) val abs_diff : t -> t -> Span.t