-
Notifications
You must be signed in to change notification settings - Fork 0
API
-
PyTimer is a class for easily timing execution of sections of codes. PyTimer supports splitting to allow different segments of code to be timed separately.
-
-
-
Allows the elapsed time to be easily checked using repeated calls to this. There must be an initial call that gets the start time.
-
display(optional): whether to display the elapsed time, or to return it as a value -
message(optional): if display==True, this message will be attached with the output that is displayed
-
-
-
A static method that allows timing a function or string of code without creating a PyTimer object
-
block: either a callable, or a string -
args: any positional arguments to be passed into block if it is a function -
reps(optional): the number of reps for each iteration -
iterations(optional): the number of iterations to average together -
display(optional): if True, then display the calculated time, else, return the value -
message(optional): if display==True, then this message will be displayed with the calculated value -
kwargs: any keyword arguments to be passed into block if it is a function
-
-
-
-
-
Calculates average for split i
-
i: Index of split to determine average for
-
-
- Returns list of averages for every split
-
-
Returns a decorator so that functions can be timed with having to use evaluate, but functions can't take any parameters
-
func: takes a function as a parameter
-
-
-
Calculates standard deviation for split i
-
i: split index
-
-
- Calculates standard deviations for every split
-
-
Display average for split i if valid index and split is not empty, otherwise displays appropriate message
-
i: split index
-
-
- Display averages for all splits unless split i is empty, in which case it is skipped
-
-
Display standard deviation for split i if valid index and split is not empty, otherwise displays appropriate message
-
i: split index
-
-
- Display standard deviation for all splits unless split is empty, in which case that split is skipped
-
- Display time since last start() or reset(). This time includes that time taken to execute PyTimer method calls
-
-
Display all values in split i if valid index and split is not empty, otherwise displays appropriate message
-
i: split index
-
-
- Display all values for all splits unless split is empty, in which case the split is skipped
-
-
Log elapsed time, log will have no affect if timer is paused
-
message(optional): optional: store message with the log
-
-
- Pause the timer, meaning no actions can be performed, allows portions of code to be skipped
-
- Clear the timer back to its defaults
-
- Resume the timer from being paused, updates the internal clock to the current time
-
-
Allow decorator to run function for multiple reps and iterations
-
reps(optional): number of times to run the function before logging the time -
iterations(optional): number of times to calculate the time
-
-
-
message(optional):
-
-
-
Times a string of code or a function and times how long it takes for each iteration. If block is a function, then parameters can be passed to it like so: time(bar, "something", 12, iterations=100) -> bar("something", 12). No error checking is done, meaning any error that is raised within block will crash the entire program.
-
block: either function or string of code -
args: any arguments that needs to be passed into block if block is a function -
reps(optional): number of reps to run the block before log is called -
iterations(optional): number of times to run rep number of times -
split_message(optional): the message that will be recorded with this split -
kwargs: keyword arguments that will be passed into block if it is a function
-
-
-
Return list of elapsed times for split i
-
i: index of split
-
-
-
Write all collected output to a file, assuming that _collect_output was set in constructor. File is either written to folder_path + basename if file_per_run is false or folder_path + basename + date_time where date_time is formatted "-day-month-year-hours-minutes-seconds". All files are written to .txt format
-
folder_path: Path of folder to write to -
basename: Name of file -
file_per_run(optional): Create a new file with every run
-
-
-