From ec7894656da1ffe3e1e0d76e793ef4e79ca2529b Mon Sep 17 00:00:00 2001 From: Eirini Koutsaniti Date: Thu, 29 Feb 2024 20:48:57 +0100 Subject: [PATCH] Add utilities function --- firecrest/utilities.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 firecrest/utilities.py diff --git a/firecrest/utilities.py b/firecrest/utilities.py new file mode 100644 index 0000000..e363904 --- /dev/null +++ b/firecrest/utilities.py @@ -0,0 +1,11 @@ +import time +from contextlib import contextmanager + +@contextmanager +def time_block(label, logger): + start_time = time.time() + try: + yield + finally: + end_time = time.time() + logger.debug(f"{label} took {end_time - start_time:.6f} seconds")