chronograph package¶
Subpackages¶
Submodules¶
chronograph.chronograph module¶
-
class
chronograph.chronograph.Chronograph(name=None, verbosity=0, logger=None, log_lvl=None, start_timing=False, throw_exceptions=False)¶ -
__init__(name=None, verbosity=0, logger=None, log_lvl=None, start_timing=False, throw_exceptions=False)¶ A class to represent a Chronograph for timing code execution
Parameters: - name – (str) a name, useful when reporting or saving global Chronographs
- verbosity – (int) set to 0=silent operation, 2=most verbose operation
- logger – (Logger) logging object for writing output. Defaults to sys.stdout
- log_lvl – (str) level to log at, e.g. “DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL”
- start_timing – (bool) set to True if you want to start timing immediately (calls the start() function)
- throw_exceptions – (bool) set to True if you want invalid Chronograph commands to result in exceptions
-
last_split¶ The complete timing data of the last completed split.
Returns: (dict)
-
last_split_time¶ The time elapsed for the last completed split.
Returns: (float)
-
report(printout=False)¶ Prints a full report of timing data as a string.
-
reset()¶ Resets and clears all timing data.
-
split(label=None)¶ Stops the current split and immediately starts a new split, perhaps with a new label.
Parameters: label – (str) a label to apply to this split (useful for reporting) Returns: (bool) if the split was created successfully (used internally)
-
start(label=None)¶ Starts timing a new split.
Parameters: label – (str) a label to apply to this split (useful for reporting)
-
stop()¶ Stops timing.
-
timing_data¶ All timing data.
Returns: (JSON array of dicts)
-
total_elapsed_time¶ The total elapsed time (all splits) for the Chronograph
Returns: (float)
-
-
exception
chronograph.chronograph.ChronographError¶ Bases:
exceptions.Exception
-
chronograph.chronograph.add_chronograph(**kwargs1)¶ A function decorator: each execution of the function will be timed as a separate split. By default the Chronograph name will be the function name.
Parameters: kwargs1 – (**kwargs1) parameters to feed into the Chronograph constructor Returns: (this is a function decorator)
-
chronograph.chronograph.get_chronograph(name, **kwargs)¶ Get a chronograph and save it the global list of chronographs
Parameters: - name – (str) the name of this chronograph
- kwargs – (**kwargs) parameters to feed into the Chronograph constructor
Returns: a Chronograph object
-
chronograph.chronograph.get_split_time(split_data, allow_still_running=False)¶