capytaine.tools.timer module

A simple timer class used to measure the time spent in various parts of the BEM solver.

class capytaine.tools.timer.Timer(timings=None)[source]

Bases: object

A simple timer class that can be used as context manager or as decorator using wraps_function method

Example

timer = Timer()
with timer:
    sleep(1.0)

print(timer.total)  # 1.0...

@timer.wraps_function
def my_function():
    sleep(0.5)

my_function()
print(timer.total)  # 1.5...
my_function()
print(timer.total)  # 2.0...

print(timer.timings)  # [1.0, 0.5, 0.5]
property mean
property nb_timings
property total
wraps_function(f)[source]