Timer#
Module provides tools for timing information.
Example
>>> import ClearMap.Utils.Timer as timer
>>> t = timer.Timer()
>>> for i in range(100000000):
>>> x = 10 + i
>>> t.print_elapsed_time('test')
- class Timer(head=None)[source]#
Bases:
objectClass to stop time and print results in formatted way
- time#
The time since the timer was started.
- Type:
float
- head#
Option prefix to the timing string.
- Type:
str or None
- elapsed_time(head=None, as_string=True)[source]#
Calculate elapsed time and return as formated string
Arguments
- head: str or None
Prefix to the timing string.
- as_string: bool
If True, return as string, else return elapsed time as float.
Returns
- time: str or float
The elapsed time information.
- format_time(t)[source]#
Format time to string.
Arguments
- t: float
Time in seconds to format.
Returns
- time: str
The time as ‘hours:minutes:seconds:milliseconds’.