mirror of
https://github.com/norohind/SquadsActivityMonitor.git
synced 2025-04-15 06:10:33 +03:00
@utils.measure decorator for debug purposes
This commit is contained in:
parent
b9d65cac7f
commit
a5218db824
23
utils.py
23
utils.py
@ -150,6 +150,29 @@ def build_index_page(app: falcon.App, index_path: str) -> None:
|
|||||||
index_file.write(index_template.format(body=app_info_str))
|
index_file.write(index_template.format(body=app_info_str))
|
||||||
|
|
||||||
|
|
||||||
|
def measure(function: callable):
|
||||||
|
"""
|
||||||
|
Decorator to measure function (method) execution time
|
||||||
|
Use as easy as
|
||||||
|
|
||||||
|
@utils.measure
|
||||||
|
def im_function_to_measure():
|
||||||
|
....
|
||||||
|
|
||||||
|
:param function:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
|
||||||
|
def decorated(*args, **kwargs):
|
||||||
|
start = time.time()
|
||||||
|
result = function(*args, **kwargs)
|
||||||
|
end = time.time()
|
||||||
|
print(f'{function.__name__}: {(end - start) * 100} ms')
|
||||||
|
return result
|
||||||
|
|
||||||
|
return decorated
|
||||||
|
|
||||||
|
|
||||||
activity_table_html_template = """
|
activity_table_html_template = """
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html lang="en-US">
|
<html lang="en-US">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user