summaryrefslogtreecommitdiffstats
path: root/testing/log_time.py
diff options
context:
space:
mode:
authorHeiner Lohaus <heiner.lohaus@netformic.com>2023-08-28 01:43:45 +0200
committerHeiner Lohaus <heiner.lohaus@netformic.com>2023-08-28 01:43:45 +0200
commit7294abc890c377d75c6c8c932620c2e2c8b3f0f9 (patch)
treef7d411570c71f5d225430d067ad64b620bb0d704 /testing/log_time.py
parent~ | code styling (diff)
downloadgpt4free-7294abc890c377d75c6c8c932620c2e2c8b3f0f9.tar
gpt4free-7294abc890c377d75c6c8c932620c2e2c8b3f0f9.tar.gz
gpt4free-7294abc890c377d75c6c8c932620c2e2c8b3f0f9.tar.bz2
gpt4free-7294abc890c377d75c6c8c932620c2e2c8b3f0f9.tar.lz
gpt4free-7294abc890c377d75c6c8c932620c2e2c8b3f0f9.tar.xz
gpt4free-7294abc890c377d75c6c8c932620c2e2c8b3f0f9.tar.zst
gpt4free-7294abc890c377d75c6c8c932620c2e2c8b3f0f9.zip
Diffstat (limited to '')
-rw-r--r--testing/log_time.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/testing/log_time.py b/testing/log_time.py
new file mode 100644
index 00000000..376ab86d
--- /dev/null
+++ b/testing/log_time.py
@@ -0,0 +1,25 @@
+from time import time
+
+
+async def log_time_async(method: callable, **kwargs):
+ start = time()
+ result = await method(**kwargs)
+ secs = f"{round(time() - start, 2)} secs"
+ if result:
+ return " ".join([result, secs])
+ return secs
+
+
+def log_time_yield(method: callable, **kwargs):
+ start = time()
+ result = yield from method(**kwargs)
+ yield f" {round(time() - start, 2)} secs"
+
+
+def log_time(method: callable, **kwargs):
+ start = time()
+ result = method(**kwargs)
+ secs = f"{round(time() - start, 2)} secs"
+ if result:
+ return " ".join([result, secs])
+ return secs \ No newline at end of file