# AUTOGENERATED! DO NOT EDIT! File to edit: timer.ipynb (unless otherwise specified).

__all__ = ['Timer', 'start_timer', 'reset_timer', 'print_time', 'print_reset']

# Cell
from .wrappers import add_class_method,add_method,add_static_method
from datetime import datetime, timedelta

# Cell
class Timer:
  def __init__(self):
    self.start_timer()
  pass


# Cell
@add_method(Timer)
def start_timer(self):
  self.t0 = datetime.now()
@add_method(Timer)
def reset_timer(self):
  self.t0 = datetime.now()

# Cell
@add_method(Timer)
def print_time(self, description = 'fuction took'):
  t1:timedelta = datetime.now() - self.t0
  print(f'{description} :{t1.total_seconds()} s')
  return t1.total_seconds()

# Cell
@add_method(Timer)
def print_reset(self, description = 'function took'):
  '''
  print_reset(self, description = 'function took')
  print and reset timer
  description: str: description of the item to print
  '''

  r = self.print_time(description = description)
  self.reset_timer()
  return r