time and profile your function
logger.setLevel(logging.DEBUG)

timer class

class Timer[source]

Timer()

This is the class that will be used for the timer

start timer

start_timer[source]

start_timer()

this method sets the starting time t0 to the current time

reset_timer[source]

reset_timer()

this method resets t0 to the current time

test

timer = Timer()
timer.t0
datetime.datetime(2021, 5, 15, 13, 3, 5, 822316)

printTime

print_time(description='fuction took')

this method subtracts the current time by t0 and prints the value in seconds to find out time between start timer and this method

description: str: this is the string to be added before the value of time taken, default = 'function took'

timer.print_time()
fuction took :0.019534 s
0.019534

print_reset(description='function took')

print and reset timer

description: str: description of the item to print

timer.print_reset('test took')
test took :0.035575 s
0.035575

Log time

log_time[source]

log_time(description='fuction took', logger=debug)

this method subtracts the current time by t0 and prints the value in seconds to find out time between start timer and this method

parameters: description: str: this is the string to be added before the value of time taken, default = 'function took' logger: callable: a callable for logging, default: logging.debug response: time:float:: time in second

test

timer.log_time()
0.014992

log_reset[source]

log_reset(description='function took', logger=debug)

print and reset timer

parameters: description: str: description of the item to print logger: callable: a callable for logging, default: logging.debug response: time:float:: time in second

test

timer.log_reset()
0.029137