pyquickbench.TimeTrain#
- class TimeTrain(path_prefix=None, include_locs=None, include_filename=True, include_lineno=True, include_funname=True, name='', align_toc_names=True, names_reduction=None, global_tictoc_sync=True, ignore_names=None, relative_timings=False)[source]#
Records elapsed time between interest points in code
See Time Trains for usage example.
- Parameters:
path_prefix (str | None)
include_locs (bool | None)
include_filename (bool)
include_lineno (bool)
include_funname (bool)
name (str)
align_toc_names (bool)
names_reduction (str | None)
global_tictoc_sync (bool)
ignore_names (Iterable[str])
relative_timings (bool)
- __init__(path_prefix=None, include_locs=None, include_filename=True, include_lineno=True, include_funname=True, name='', align_toc_names=True, names_reduction=None, global_tictoc_sync=True, ignore_names=None, relative_timings=False)[source]#
Returns a TimeTrain
- Parameters:
path_prefix (
str
|None
, optional) – Path relative to which other paths are to be understood, by defaultNone
.include_locs (
bool
| None, optional) – Whether to include locations in code when printing the TimeTrain, by defaultNone
.include_filename (
bool
, optional) – Whether to include the file name in locations in code when printing the TimeTrain, by defaultTrue
.include_lineno (
bool
, optional) – Whether to include the line number in locations in code when printing the TimeTrain, by defaultTrue
.include_funname (
bool
, optional) – Whether to include the function name in locations in code when printing the TimeTrain, by defaultTrue
.name (
str
, optional) – Name of the TimeTrain, by default''
.align_toc_names (
bool
, optional) – Whether to align toc names when printing the TimeTrain, by defaultTrue
.names_reduction (
str
|None
, optional) – Reduction to be applied to tocs that share the same name, by defaultNone
.global_tictoc_sync (
bool
, optional) – Set toTrue
to use a common shared name for synchronization inpyquickbench.TimeTrain.tictoc()
or toFalse
to use a specific name for every decorated function. By defaultTrue
.ignore_names (
str
|None
, optional) – Names to be ignored byprint()
andpyquickbench.TimeTrain.to_dict()
. By defaultNone
.relative_timings (
bool
, optional) – Whether to display relative timings when printing the TimeTrain. Relative timings only sum up to 100% ifnames_reduction
isNone
or"sum"
. By defaultFalse
.
Methods
__init__
([path_prefix, include_locs, ...])Returns a TimeTrain
to_dict
([return_first_instance, names_reduction])Returns time measurements within a TimeTrain as a Python dictionary
toc
([name])Records a new wagon in the TimeTrain.
Attributes
Decorates a function to record a new wagon in the TimeTrain before and after each call.
Returns the total time recorded by the TimeTrain so far.