QuickTimer package¶
Module contents¶
- class quicktimer.Timer(time_unit='timedelta', decimals_percentage=2, decimals_time=4, output_func=<built-in function print>)¶
Bases:
object
- delete_timestamps()¶
Deletes any stored timestamps including descriptions.
- fancy_print(delete=True)¶
Fancy prints the entire time taken, the differences between the individual timestamps in absolute seconds & in percentages as well as the descriptions.
- Parameters
delete (bool, optional) – deletes the currently stored list of timestamps after ouput, defaults to True
- get_descriptions()¶
Returns the stored descriptions.
If no description was supplied when take_time was called, the value is an empty String.
- Returns
List of stored descriptions.
- Return type
List<str>
- get_timestamps()¶
Returns the timestamps including the descriptions as a List of Tuples.
- Returns
A list of timestamps and discriptions.
- Return type
List<(datetime, str)>
- set_output_func(output_func)¶
Sets the output function of the module.
- Parameters
output_func (function, optional) – a function to output messages (e.g. logger.info or print)
- set_time_unit(time_unit)¶
Set the unit in which the time is being displayed.
- Acceptable values:
“timedelta”
“seconds”
“milliseconds”
- Parameters
time_unit (str, optional) – Unit in which time measurements are displayed
- Raises
ValueError – when an unacceptable time_unit is passed as parameter.
- take_time(description='', printme=False)¶
Snapshots the current time and inserts it into the List as a Tuple with the passed description.
- Parameters
description (str) – Gets saved alongside the timestamp. Use it as a descriptor of what happened before the function was called, defaults to empty String
printme (bool) – Enable printing the description after taking a snapshot of the time. Use this parameter to keep track of the code progress during runtime, defaults to False