From Learning Python book, here is an example of a decorator that can track time usage of a function

import numpy as np
from typing import Any
import time

class Timer:
    
    def __init__(self, func) -> None:
        self.func = func
        self.alltime = 0

    def __call__(self, *args: Any, **kwargs: Any) -> Any:
        start = time.time()
        result = self.func(*args, **kwargs)
        elapsed = time.time() - start
        self.alltime += elapsed
        print('{}: Call time \\'{}\\', Total Time \\'{}\\''.format(self.func.__name__, elapsed, self.alltime))
        return result
    
@Timer
def make_array(length):
    return np.arange(length)

thing = make_array(30000)
print(thing)