From f893f14f21aef0e74583e092623583d72486bbfe Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 24 Mar 2021 12:06:53 -0400 Subject: [PATCH] feat(profile): `enabled` function --- src/util/Profile.ml | 2 ++ src/util/Profile.mli | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/util/Profile.ml b/src/util/Profile.ml index c0d6b6ca..76737126 100644 --- a/src/util/Profile.ml +++ b/src/util/Profile.ml @@ -32,6 +32,8 @@ let null_probe = No_probe (* where to print events *) let out_ : backend option ref = ref None +let[@inline] enabled () = match !out_ with Some _ -> true | None -> false + let begin_with_ (module B:BACKEND) name : probe = Probe {name; start=B.get_ts ()} diff --git a/src/util/Profile.mli b/src/util/Profile.mli index ea3bb498..01cbc003 100644 --- a/src/util/Profile.mli +++ b/src/util/Profile.mli @@ -5,6 +5,8 @@ type probe val null_probe : probe +val enabled : unit -> bool + val instant : string -> unit val begin_ : string -> probe