mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
30 lines
788 B
Python
30 lines
788 B
Python
import time
|
|
from openpype.api import Logger
|
|
log = Logger().get_logger("SyncServer")
|
|
|
|
|
|
class SyncStatus:
|
|
DO_NOTHING = 0
|
|
DO_UPLOAD = 1
|
|
DO_DOWNLOAD = 2
|
|
|
|
|
|
def time_function(method):
|
|
""" Decorator to print how much time function took.
|
|
For debugging.
|
|
Depends on presence of 'log' object
|
|
"""
|
|
|
|
def timed(*args, **kw):
|
|
ts = time.time()
|
|
result = method(*args, **kw)
|
|
te = time.time()
|
|
if 'log_time' in kw:
|
|
name = kw.get('log_name', method.__name__.upper())
|
|
kw['log_time'][name] = int((te - ts) * 1000)
|
|
else:
|
|
log.debug('%r %2.2f ms' % (method.__name__, (te - ts) * 1000))
|
|
print('%r %2.2f ms' % (method.__name__, (te - ts) * 1000))
|
|
return result
|
|
|
|
return timed
|