perturbopy.postproc.utils.timing.TimingGroup
- class perturbopy.postproc.utils.timing.TimingGroup(name=None)
Bases:
objectClass to group and manage multiple timing measurements.
- timings
A dictionary of tag-timing pairs.
- Type:
OrderedDict
- add(tag, level=0)
Add a new timing measurement with the given tag.
- sort()
Sort the timings based on the total runtime.
Examples
>>> timing_group = TimingGroup() >>> >>> with timing_group.add('SVD') as t_svd: ... # Code to be timed for SVD ... time.sleep(1) ... >>> with timing_group.add('DIAGO') as t_diago: ... # Code to be timed for DIAGO ... time.sleep(2) ... >>> print(t_svd) SVD (s): Total Runtime: 1.000, Call Count: 1 >>> >>> timing_group.print_timings() SVD (s): Total Runtime: 1.000, Call Count: 1 DIAGO (s): Total Runtime: 2.000, Call Count: 1
Methods
Add timing to existing tag or create a new one.
Return a dictionary of timings.
- add(tag, level=0)
Add timing to existing tag or create a new one.
- to_dict()
Return a dictionary of timings.
- Returns:
A dictionary containing the tag-timing pairs.
- Return type:
dict