mirror of https://github.com/xtekky/gpt4free
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
615 B
Python
25 lines
615 B
Python
1 year ago
|
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])
|
||
1 year ago
|
return secs
|