From a2c397f1e524dfa6b0c1f0fba82d88aa361c0735 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 27 Apr 2021 23:04:20 -0400 Subject: [PATCH] feat(profile): util `with2` --- src/util/Profile.ml | 3 +++ src/util/Profile.mli | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/Profile.ml b/src/util/Profile.ml index 76737126..b0c25a3a 100644 --- a/src/util/Profile.ml +++ b/src/util/Profile.ml @@ -90,6 +90,9 @@ let[@inline] with1 name f x = exit_with_ b pb; raise e +let[@inline] with2 name f x y = + with_ name (fun () -> f x y) + module Control = struct let setup b = assert (!out_ = None); diff --git a/src/util/Profile.mli b/src/util/Profile.mli index 01cbc003..ec5055ba 100644 --- a/src/util/Profile.mli +++ b/src/util/Profile.mli @@ -14,8 +14,8 @@ val begin_ : string -> probe val exit : probe -> unit val with_ : string -> (unit -> 'a) -> 'a - val with1 : string -> ('a -> 'b) -> 'a -> 'b +val with2 : string -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c module type BACKEND = sig val get_ts : unit -> float