timeit

lsst.ts.MTAOS.timeit(func)

Decorator to compute execution time.

Add this decorator to a method to allow computing execution times.

Parameters
funcfunction or coroutine

Method to be decorated.

Examples

Timing a regular method.

>>> @timeit
    def my_method(arg1, arg2, **kwargs):
        # Do something here....

Timing a coroutine

>>> @timeit
    async def my_coroutine(arg1, arg2, **kwargs):
        # Do something here....
>>> log_time = dict()
>>> ret_val_1 = my_method(arg1=arg1, arg2=arg2, log_time=log_time)
>>> log_time
{'MY_METHOD': [6.699992809444666e-06]}
>>> ret_val_2 = await my_coroutine(arg1=arg1, arg2=arg2, log_time=log_time)
>>> log_time
{'MY_METHOD': [6.699992809444666e-06],
'MY_COROUTINE': [1.2299977242946625e-05]}