# Path: gtimer/local/times.py
# class Times(object):
#     """ Timing data resides here, including tree structure.
#     (Survives after timing is complete).
#     """
# 
#     def __init__(self,
#                  name=None,
#                  parent=None,
#                  pos_in_parent=None,
#                  save_itrs=True):
#         self.name = None if name is None else str(name)
#         self.parent = parent  # refer to another Times instance.
#         self.pos_in_parent = pos_in_parent  # refers to a stamp name.
#         self.save_itrs = save_itrs
#         self.reset()
# 
#     def __deepcopy__(self, memo):
#         new = type(self)()
#         new.__dict__.update(self.__dict__)
#         new.stamps = copy.deepcopy(self.stamps, memo)
#         new.subdvsn = copy.deepcopy(new.subdvsn, memo)
#         new.par_subdvsn = copy.deepcopy(self.par_subdvsn, memo)
#         # Avoid deepcopy of parent, and update that attribute.
#         for sub_list in itervalues(new.subdvsn):
#             for sub in sub_list:
#                 sub.parent = new
#         for par_dict in itervalues(new.par_subdvsn):
#             for par_list in itervalues(par_dict):
#                 for sub in par_list:
#                     sub.parent = new
#         return new
# 
#     def reset(self):
#         self.stamps = Stamps()
#         self.total = 0.
#         self.stamps_sum = 0.
#         self.self_agg = 0.
#         self.subdvsn = dict()
#         self.par_subdvsn = dict()
#         self.par_in_parent = None
# 
# Path: gtimer/util.py
# def itervalues(dictionary):
#     return dictionary.values()


from timeit import default_timer as timer
from gtimer.local.times import Times
from gtimer.util import itervalues
import copy

class Timer(object):
    """ Current (temporary) values describing state of timer.
    (Disappears or irrelevant after timing is complete.)
    """

    def __init__(self,
                 name,
                 rgstr_stamps=None,
                 dump=None,
                 is_named_loop=False,
                 in_loop=False,
                 **kwargs):
        self.name = str(name)
        self.rgstr_stamps = rgstr_stamps if rgstr_stamps is not None else list()
        self.dump = dump  # refers to a Times instance, not a Timer instance
        self.is_named_loop = is_named_loop  # needed for copying dump and self agg
        self.in_loop = bool(in_loop)
        self.times = None
        self.is_user_subdvsn = False
        self.reset()
        self.times = Times(name, **kwargs)

    def __deepcopy__(self, memo):
        new = type(self)(self.name)
        new.__dict__.update(self.__dict__)
        new.subdvsn_awaiting = copy.deepcopy(self.subdvsn_awaiting, memo)
        new.par_subdvsn_awaiting = copy.deepcopy(self.par_subdvsn_awaiting, memo)
        for sub_times in itervalues(new.subdvsn_awaiting):
            sub_times.parent = new.times

# Path: gtimer/local/times.py
# class Times(object):
#     """ Timing data resides here, including tree structure.
#     (Survives after timing is complete).
#     """
# 
#     def __init__(self,
#                  name=None,
#                  parent=None,
#                  pos_in_parent=None,
#                  save_itrs=True):
#         self.name = None if name is None else str(name)
#         self.parent = parent  # refer to another Times instance.
#         self.pos_in_parent = pos_in_parent  # refers to a stamp name.
#         self.save_itrs = save_itrs
#         self.reset()
# 
#     def __deepcopy__(self, memo):
#         new = type(self)()
#         new.__dict__.update(self.__dict__)
#         new.stamps = copy.deepcopy(self.stamps, memo)
#         new.subdvsn = copy.deepcopy(new.subdvsn, memo)
#         new.par_subdvsn = copy.deepcopy(self.par_subdvsn, memo)
#         # Avoid deepcopy of parent, and update that attribute.
#         for sub_list in itervalues(new.subdvsn):
#             for sub in sub_list:
#                 sub.parent = new
#         for par_dict in itervalues(new.par_subdvsn):
#             for par_list in itervalues(par_dict):
#                 for sub in par_list:
#                     sub.parent = new
#         return new
# 
#     def reset(self):
#         self.stamps = Stamps()
#         self.total = 0.
#         self.stamps_sum = 0.
#         self.self_agg = 0.
#         self.subdvsn = dict()
#         self.par_subdvsn = dict()
#         self.par_in_parent = None
# 
# Path: gtimer/util.py
# def itervalues(dictionary):
#     return dictionary.values()


# Path: gtimer/local/timer.py
from timeit import default_timer as timer
from gtimer.local.times import Times
from gtimer.util import itervalues
import copy


class Timer(object):
    """ Current (temporary) values describing state of timer.
    (Disappears or irrelevant after timing is complete.)
    """

    def __init__(self,
                 name,
                 rgstr_stamps=None,
                 dump=None,
                 is_named_loop=False,
                 in_loop=False,
                 **kwargs):
        self.name = str(name)
        self.rgstr_stamps = rgstr_stamps if rgstr_stamps is not None else list()
        self.dump = dump  # refers to a Times instance, not a Timer instance
        self.is_named_loop = is_named_loop  # needed for copying dump and self agg
        self.in_loop = bool(in_loop)
        self.times = None
        self.is_user_subdvsn = False
        self.reset()
        self.times = Times(name, **kwargs)

    def __deepcopy__(self, memo):
        new = type(self)(self.name)
        new.__dict__.update(self.__dict__)
        new.subdvsn_awaiting = copy.deepcopy(self.subdvsn_awaiting, memo)
        new.par_subdvsn_awaiting = copy.deepcopy(self.par_subdvsn_awaiting, memo)
        for sub_times in itervalues(new.subdvsn_awaiting):
            sub_times.parent = new.times

        for sub_list in itervalues(new.par_subdvsn_awaiting):