Timer Usage#

The pydecorium.decorators.Timer decorator is used to measure the runtime of a function. Timer is a sub-class of the class pydecorium.ProfilerUtils and can be use for the pydecorium.decorators.FunctionProfiler decorator. In this example, we will only show how to use the Timer decorator as a standalone decorator. The usage of the Timer decorator into the FunctionProfiler decorator is described in the documentation FunctionProfiler Usage.

First we need to import the Timer decorator with the following command:

from pydecorium.decorators import Timer

Then we can use the Timer as describe in the documentation How to use a decorator.

timer = Timer(activated=True, signature_name_format='{name}')

@timer
def example_function():
    import time
    print("Hello")
    time.sleep(70)

example_function()

The output will be:

Hello
example_function - runtime : 0h 1m 10.0000s